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_add_drive_ro\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_set_append\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_get_append\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
111 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
112 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
113 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
114 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
115 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
116 fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
117 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
118 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
119 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
120 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
121 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
122 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
123 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
124 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
125 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
126 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
127 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
128 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
129 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
130 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
131 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
132 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
133 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
134 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
135 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
136 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
137 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
138 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
139 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
140 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
141 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
142 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
143 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
144 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
145 fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
146 fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
147 fprintf (stderr, "warning: \"guestfs_pvresize\" has no tests\n");
148 fprintf (stderr, "warning: \"guestfs_sfdisk_N\" has no tests\n");
149 fprintf (stderr, "warning: \"guestfs_sfdisk_l\" has no tests\n");
150 fprintf (stderr, "warning: \"guestfs_sfdisk_kernel_geometry\" has no tests\n");
151 fprintf (stderr, "warning: \"guestfs_sfdisk_disk_geometry\" has no tests\n");
152 fprintf (stderr, "warning: \"guestfs_vg_activate_all\" has no tests\n");
153 fprintf (stderr, "warning: \"guestfs_vg_activate\" has no tests\n");
154 fprintf (stderr, "warning: \"guestfs_resize2fs\" has no tests\n");
155 fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
158 static int test_sleep_0_skip (void)
162 str = getenv ("SKIP_TEST_SLEEP_0");
163 if (str && strcmp (str, "1") == 0) return 1;
164 str = getenv ("SKIP_TEST_SLEEP");
165 if (str && strcmp (str, "1") == 0) return 1;
169 static int test_sleep_0 (void)
171 if (test_sleep_0_skip ()) {
172 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_sleep_0");
176 /* InitNone|InitEmpty for test_sleep_0 */
178 char device[] = "/dev/sda";
182 r = guestfs_blockdev_setrw (g, device);
189 r = guestfs_umount_all (g);
196 r = guestfs_lvm_remove_all (g);
200 /* TestRun for sleep (0) */
204 r = guestfs_sleep (g, 1);
211 static int test_find_0_skip (void)
215 str = getenv ("SKIP_TEST_FIND_0");
216 if (str && strcmp (str, "1") == 0) return 1;
217 str = getenv ("SKIP_TEST_FIND");
218 if (str && strcmp (str, "1") == 0) return 1;
222 static int test_find_0 (void)
224 if (test_find_0_skip ()) {
225 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_0");
229 /* InitBasicFS for test_find_0: create ext2 on /dev/sda1 */
231 char device[] = "/dev/sda";
235 r = guestfs_blockdev_setrw (g, device);
242 r = guestfs_umount_all (g);
249 r = guestfs_lvm_remove_all (g);
254 char device[] = "/dev/sda";
256 char lines_0[] = ",";
263 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
268 char fstype[] = "ext2";
269 char device[] = "/dev/sda1";
273 r = guestfs_mkfs (g, fstype, device);
278 char device[] = "/dev/sda1";
280 char mountpoint[] = "/";
283 r = guestfs_mount (g, device, mountpoint);
287 /* TestOutputList for find (0) */
289 char directory[] = "/";
293 r = guestfs_find (g, directory);
297 fprintf (stderr, "test_find_0: short list returned from command\n");
302 char expected[] = "lost+found";
303 if (strcmp (r[0], expected) != 0) {
304 fprintf (stderr, "test_find_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
309 fprintf (stderr, "test_find_0: extra elements returned from command\n");
313 for (i = 0; r[i] != NULL; ++i)
320 static int test_find_1_skip (void)
324 str = getenv ("SKIP_TEST_FIND_1");
325 if (str && strcmp (str, "1") == 0) return 1;
326 str = getenv ("SKIP_TEST_FIND");
327 if (str && strcmp (str, "1") == 0) return 1;
331 static int test_find_1 (void)
333 if (test_find_1_skip ()) {
334 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_1");
338 /* InitBasicFS for test_find_1: create ext2 on /dev/sda1 */
340 char device[] = "/dev/sda";
344 r = guestfs_blockdev_setrw (g, device);
351 r = guestfs_umount_all (g);
358 r = guestfs_lvm_remove_all (g);
363 char device[] = "/dev/sda";
365 char lines_0[] = ",";
372 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
377 char fstype[] = "ext2";
378 char device[] = "/dev/sda1";
382 r = guestfs_mkfs (g, fstype, device);
387 char device[] = "/dev/sda1";
389 char mountpoint[] = "/";
392 r = guestfs_mount (g, device, mountpoint);
396 /* TestOutputList for find (1) */
401 r = guestfs_touch (g, path);
409 r = guestfs_mkdir (g, path);
414 char path[] = "/b/c";
417 r = guestfs_touch (g, path);
422 char directory[] = "/";
426 r = guestfs_find (g, directory);
430 fprintf (stderr, "test_find_1: short list returned from command\n");
435 char expected[] = "a";
436 if (strcmp (r[0], expected) != 0) {
437 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
442 fprintf (stderr, "test_find_1: short list returned from command\n");
447 char expected[] = "b";
448 if (strcmp (r[1], expected) != 0) {
449 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
454 fprintf (stderr, "test_find_1: short list returned from command\n");
459 char expected[] = "b/c";
460 if (strcmp (r[2], expected) != 0) {
461 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
466 fprintf (stderr, "test_find_1: short list returned from command\n");
471 char expected[] = "lost+found";
472 if (strcmp (r[3], expected) != 0) {
473 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[3]);
478 fprintf (stderr, "test_find_1: extra elements returned from command\n");
482 for (i = 0; r[i] != NULL; ++i)
489 static int test_find_2_skip (void)
493 str = getenv ("SKIP_TEST_FIND_2");
494 if (str && strcmp (str, "1") == 0) return 1;
495 str = getenv ("SKIP_TEST_FIND");
496 if (str && strcmp (str, "1") == 0) return 1;
500 static int test_find_2 (void)
502 if (test_find_2_skip ()) {
503 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_2");
507 /* InitBasicFS for test_find_2: create ext2 on /dev/sda1 */
509 char device[] = "/dev/sda";
513 r = guestfs_blockdev_setrw (g, device);
520 r = guestfs_umount_all (g);
527 r = guestfs_lvm_remove_all (g);
532 char device[] = "/dev/sda";
534 char lines_0[] = ",";
541 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
546 char fstype[] = "ext2";
547 char device[] = "/dev/sda1";
551 r = guestfs_mkfs (g, fstype, device);
556 char device[] = "/dev/sda1";
558 char mountpoint[] = "/";
561 r = guestfs_mount (g, device, mountpoint);
565 /* TestOutputList for find (2) */
567 char path[] = "/a/b/c";
570 r = guestfs_mkdir_p (g, path);
575 char path[] = "/a/b/c/d";
578 r = guestfs_touch (g, path);
583 char directory[] = "/a/b/";
587 r = guestfs_find (g, directory);
591 fprintf (stderr, "test_find_2: short list returned from command\n");
596 char expected[] = "c";
597 if (strcmp (r[0], expected) != 0) {
598 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
603 fprintf (stderr, "test_find_2: short list returned from command\n");
608 char expected[] = "c/d";
609 if (strcmp (r[1], expected) != 0) {
610 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
615 fprintf (stderr, "test_find_2: extra elements returned from command\n");
619 for (i = 0; r[i] != NULL; ++i)
626 static int test_lvresize_0_skip (void)
630 str = getenv ("SKIP_TEST_LVRESIZE_0");
631 if (str && strcmp (str, "1") == 0) return 1;
632 str = getenv ("SKIP_TEST_LVRESIZE");
633 if (str && strcmp (str, "1") == 0) return 1;
637 static int test_lvresize_0 (void)
639 if (test_lvresize_0_skip ()) {
640 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvresize_0");
644 /* InitNone|InitEmpty for test_lvresize_0 */
646 char device[] = "/dev/sda";
650 r = guestfs_blockdev_setrw (g, device);
657 r = guestfs_umount_all (g);
664 r = guestfs_lvm_remove_all (g);
668 /* TestOutput for lvresize (0) */
669 char expected[] = "test content";
671 char device[] = "/dev/sda";
673 char lines_0[] = ",";
680 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
685 char device[] = "/dev/sda1";
689 r = guestfs_pvcreate (g, device);
694 char volgroup[] = "VG";
695 char physvols_0[] = "/dev/sda1";
696 physvols_0[5] = devchar;
703 r = guestfs_vgcreate (g, volgroup, physvols);
708 char logvol[] = "LV";
709 char volgroup[] = "VG";
712 r = guestfs_lvcreate (g, logvol, volgroup, 10);
717 char fstype[] = "ext2";
718 char device[] = "/dev/VG/LV";
721 r = guestfs_mkfs (g, fstype, device);
726 char device[] = "/dev/VG/LV";
727 char mountpoint[] = "/";
730 r = guestfs_mount (g, device, mountpoint);
735 char path[] = "/new";
736 char content[] = "test content";
739 r = guestfs_write_file (g, path, content, 0);
744 char pathordevice[] = "/";
747 r = guestfs_umount (g, pathordevice);
752 char device[] = "/dev/VG/LV";
755 r = guestfs_lvresize (g, device, 20);
760 char device[] = "/dev/VG/LV";
763 r = guestfs_e2fsck_f (g, device);
768 char device[] = "/dev/VG/LV";
771 r = guestfs_resize2fs (g, device);
776 char device[] = "/dev/VG/LV";
777 char mountpoint[] = "/";
780 r = guestfs_mount (g, device, mountpoint);
785 char path[] = "/new";
788 r = guestfs_cat (g, path);
791 if (strcmp (r, expected) != 0) {
792 fprintf (stderr, "test_lvresize_0: expected \"%s\" but got \"%s\"\n", expected, r);
800 static int test_zerofree_0_skip (void)
804 str = getenv ("SKIP_TEST_ZEROFREE_0");
805 if (str && strcmp (str, "1") == 0) return 1;
806 str = getenv ("SKIP_TEST_ZEROFREE");
807 if (str && strcmp (str, "1") == 0) return 1;
811 static int test_zerofree_0 (void)
813 if (test_zerofree_0_skip ()) {
814 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zerofree_0");
818 /* InitNone|InitEmpty for test_zerofree_0 */
820 char device[] = "/dev/sda";
824 r = guestfs_blockdev_setrw (g, device);
831 r = guestfs_umount_all (g);
838 r = guestfs_lvm_remove_all (g);
842 /* TestOutput for zerofree (0) */
843 char expected[] = "test file";
845 char device[] = "/dev/sda";
847 char lines_0[] = ",";
854 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
859 char fstype[] = "ext3";
860 char device[] = "/dev/sda1";
864 r = guestfs_mkfs (g, fstype, device);
869 char device[] = "/dev/sda1";
871 char mountpoint[] = "/";
874 r = guestfs_mount (g, device, mountpoint);
879 char path[] = "/new";
880 char content[] = "test file";
883 r = guestfs_write_file (g, path, content, 0);
888 char pathordevice[] = "/dev/sda1";
889 pathordevice[5] = devchar;
892 r = guestfs_umount (g, pathordevice);
897 char device[] = "/dev/sda1";
901 r = guestfs_zerofree (g, device);
906 char device[] = "/dev/sda1";
908 char mountpoint[] = "/";
911 r = guestfs_mount (g, device, mountpoint);
916 char path[] = "/new";
919 r = guestfs_cat (g, path);
922 if (strcmp (r, expected) != 0) {
923 fprintf (stderr, "test_zerofree_0: expected \"%s\" but got \"%s\"\n", expected, r);
931 static int test_hexdump_0_skip (void)
935 str = getenv ("SKIP_TEST_HEXDUMP_0");
936 if (str && strcmp (str, "1") == 0) return 1;
937 str = getenv ("SKIP_TEST_HEXDUMP");
938 if (str && strcmp (str, "1") == 0) return 1;
942 static int test_hexdump_0 (void)
944 if (test_hexdump_0_skip ()) {
945 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_hexdump_0");
949 /* InitBasicFS for test_hexdump_0: create ext2 on /dev/sda1 */
951 char device[] = "/dev/sda";
955 r = guestfs_blockdev_setrw (g, device);
962 r = guestfs_umount_all (g);
969 r = guestfs_lvm_remove_all (g);
974 char device[] = "/dev/sda";
976 char lines_0[] = ",";
983 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
988 char fstype[] = "ext2";
989 char device[] = "/dev/sda1";
993 r = guestfs_mkfs (g, fstype, device);
998 char device[] = "/dev/sda1";
1000 char mountpoint[] = "/";
1003 r = guestfs_mount (g, device, mountpoint);
1007 /* TestOutput for hexdump (0) */
1008 char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
1010 char path[] = "/new";
1011 char content[] = "hello\nworld\n";
1014 r = guestfs_write_file (g, path, content, 12);
1019 char path[] = "/new";
1022 r = guestfs_hexdump (g, path);
1025 if (strcmp (r, expected) != 0) {
1026 fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
1034 static int test_strings_e_0_skip (void)
1038 str = getenv ("SKIP_TEST_STRINGS_E_0");
1039 if (str && strcmp (str, "1") == 0) return 1;
1040 str = getenv ("SKIP_TEST_STRINGS_E");
1041 if (str && strcmp (str, "1") == 0) return 1;
1045 static int test_strings_e_0 (void)
1047 if (test_strings_e_0_skip ()) {
1048 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_0");
1052 /* InitBasicFS for test_strings_e_0: create ext2 on /dev/sda1 */
1054 char device[] = "/dev/sda";
1055 device[5] = devchar;
1058 r = guestfs_blockdev_setrw (g, device);
1065 r = guestfs_umount_all (g);
1072 r = guestfs_lvm_remove_all (g);
1077 char device[] = "/dev/sda";
1078 device[5] = devchar;
1079 char lines_0[] = ",";
1086 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1091 char fstype[] = "ext2";
1092 char device[] = "/dev/sda1";
1093 device[5] = devchar;
1096 r = guestfs_mkfs (g, fstype, device);
1101 char device[] = "/dev/sda1";
1102 device[5] = devchar;
1103 char mountpoint[] = "/";
1106 r = guestfs_mount (g, device, mountpoint);
1110 /* TestOutputList for strings_e (0) */
1112 char path[] = "/new";
1113 char content[] = "hello\nworld\n";
1116 r = guestfs_write_file (g, path, content, 0);
1121 char encoding[] = "b";
1122 char path[] = "/new";
1126 r = guestfs_strings_e (g, encoding, path);
1130 fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
1134 for (i = 0; r[i] != NULL; ++i)
1141 static int test_strings_e_1_skip (void)
1145 str = getenv ("SKIP_TEST_STRINGS_E_1");
1146 if (str && strcmp (str, "1") == 0) return 1;
1147 str = getenv ("SKIP_TEST_STRINGS_E");
1148 if (str && strcmp (str, "1") == 0) return 1;
1152 static int test_strings_e_1 (void)
1154 if (test_strings_e_1_skip ()) {
1155 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_1");
1159 printf ("%s skipped (reason: test disabled in generator)\n", "test_strings_e_1");
1163 static int test_strings_0_skip (void)
1167 str = getenv ("SKIP_TEST_STRINGS_0");
1168 if (str && strcmp (str, "1") == 0) return 1;
1169 str = getenv ("SKIP_TEST_STRINGS");
1170 if (str && strcmp (str, "1") == 0) return 1;
1174 static int test_strings_0 (void)
1176 if (test_strings_0_skip ()) {
1177 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_0");
1181 /* InitBasicFS for test_strings_0: create ext2 on /dev/sda1 */
1183 char device[] = "/dev/sda";
1184 device[5] = devchar;
1187 r = guestfs_blockdev_setrw (g, device);
1194 r = guestfs_umount_all (g);
1201 r = guestfs_lvm_remove_all (g);
1206 char device[] = "/dev/sda";
1207 device[5] = devchar;
1208 char lines_0[] = ",";
1215 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1220 char fstype[] = "ext2";
1221 char device[] = "/dev/sda1";
1222 device[5] = devchar;
1225 r = guestfs_mkfs (g, fstype, device);
1230 char device[] = "/dev/sda1";
1231 device[5] = devchar;
1232 char mountpoint[] = "/";
1235 r = guestfs_mount (g, device, mountpoint);
1239 /* TestOutputList for strings (0) */
1241 char path[] = "/new";
1242 char content[] = "hello\nworld\n";
1245 r = guestfs_write_file (g, path, content, 0);
1250 char path[] = "/new";
1254 r = guestfs_strings (g, path);
1258 fprintf (stderr, "test_strings_0: short list returned from command\n");
1263 char expected[] = "hello";
1264 if (strcmp (r[0], expected) != 0) {
1265 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
1270 fprintf (stderr, "test_strings_0: short list returned from command\n");
1275 char expected[] = "world";
1276 if (strcmp (r[1], expected) != 0) {
1277 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
1282 fprintf (stderr, "test_strings_0: extra elements returned from command\n");
1286 for (i = 0; r[i] != NULL; ++i)
1293 static int test_strings_1_skip (void)
1297 str = getenv ("SKIP_TEST_STRINGS_1");
1298 if (str && strcmp (str, "1") == 0) return 1;
1299 str = getenv ("SKIP_TEST_STRINGS");
1300 if (str && strcmp (str, "1") == 0) return 1;
1304 static int test_strings_1 (void)
1306 if (test_strings_1_skip ()) {
1307 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_1");
1311 /* InitBasicFS for test_strings_1: create ext2 on /dev/sda1 */
1313 char device[] = "/dev/sda";
1314 device[5] = devchar;
1317 r = guestfs_blockdev_setrw (g, device);
1324 r = guestfs_umount_all (g);
1331 r = guestfs_lvm_remove_all (g);
1336 char device[] = "/dev/sda";
1337 device[5] = devchar;
1338 char lines_0[] = ",";
1345 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1350 char fstype[] = "ext2";
1351 char device[] = "/dev/sda1";
1352 device[5] = devchar;
1355 r = guestfs_mkfs (g, fstype, device);
1360 char device[] = "/dev/sda1";
1361 device[5] = devchar;
1362 char mountpoint[] = "/";
1365 r = guestfs_mount (g, device, mountpoint);
1369 /* TestOutputList for strings (1) */
1371 char path[] = "/new";
1374 r = guestfs_touch (g, path);
1379 char path[] = "/new";
1383 r = guestfs_strings (g, path);
1387 fprintf (stderr, "test_strings_1: extra elements returned from command\n");
1391 for (i = 0; r[i] != NULL; ++i)
1398 static int test_equal_0_skip (void)
1402 str = getenv ("SKIP_TEST_EQUAL_0");
1403 if (str && strcmp (str, "1") == 0) return 1;
1404 str = getenv ("SKIP_TEST_EQUAL");
1405 if (str && strcmp (str, "1") == 0) return 1;
1409 static int test_equal_0 (void)
1411 if (test_equal_0_skip ()) {
1412 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_0");
1416 /* InitBasicFS for test_equal_0: create ext2 on /dev/sda1 */
1418 char device[] = "/dev/sda";
1419 device[5] = devchar;
1422 r = guestfs_blockdev_setrw (g, device);
1429 r = guestfs_umount_all (g);
1436 r = guestfs_lvm_remove_all (g);
1441 char device[] = "/dev/sda";
1442 device[5] = devchar;
1443 char lines_0[] = ",";
1450 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1455 char fstype[] = "ext2";
1456 char device[] = "/dev/sda1";
1457 device[5] = devchar;
1460 r = guestfs_mkfs (g, fstype, device);
1465 char device[] = "/dev/sda1";
1466 device[5] = devchar;
1467 char mountpoint[] = "/";
1470 r = guestfs_mount (g, device, mountpoint);
1474 /* TestOutputTrue for equal (0) */
1476 char path[] = "/file1";
1477 char content[] = "contents of a file";
1480 r = guestfs_write_file (g, path, content, 0);
1485 char src[] = "/file1";
1486 char dest[] = "/file2";
1489 r = guestfs_cp (g, src, dest);
1494 char file1[] = "/file1";
1495 char file2[] = "/file2";
1498 r = guestfs_equal (g, file1, file2);
1502 fprintf (stderr, "test_equal_0: expected true, got false\n");
1509 static int test_equal_1_skip (void)
1513 str = getenv ("SKIP_TEST_EQUAL_1");
1514 if (str && strcmp (str, "1") == 0) return 1;
1515 str = getenv ("SKIP_TEST_EQUAL");
1516 if (str && strcmp (str, "1") == 0) return 1;
1520 static int test_equal_1 (void)
1522 if (test_equal_1_skip ()) {
1523 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_1");
1527 /* InitBasicFS for test_equal_1: create ext2 on /dev/sda1 */
1529 char device[] = "/dev/sda";
1530 device[5] = devchar;
1533 r = guestfs_blockdev_setrw (g, device);
1540 r = guestfs_umount_all (g);
1547 r = guestfs_lvm_remove_all (g);
1552 char device[] = "/dev/sda";
1553 device[5] = devchar;
1554 char lines_0[] = ",";
1561 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1566 char fstype[] = "ext2";
1567 char device[] = "/dev/sda1";
1568 device[5] = devchar;
1571 r = guestfs_mkfs (g, fstype, device);
1576 char device[] = "/dev/sda1";
1577 device[5] = devchar;
1578 char mountpoint[] = "/";
1581 r = guestfs_mount (g, device, mountpoint);
1585 /* TestOutputFalse for equal (1) */
1587 char path[] = "/file1";
1588 char content[] = "contents of a file";
1591 r = guestfs_write_file (g, path, content, 0);
1596 char path[] = "/file2";
1597 char content[] = "contents of another file";
1600 r = guestfs_write_file (g, path, content, 0);
1605 char file1[] = "/file1";
1606 char file2[] = "/file2";
1609 r = guestfs_equal (g, file1, file2);
1613 fprintf (stderr, "test_equal_1: expected false, got true\n");
1620 static int test_equal_2_skip (void)
1624 str = getenv ("SKIP_TEST_EQUAL_2");
1625 if (str && strcmp (str, "1") == 0) return 1;
1626 str = getenv ("SKIP_TEST_EQUAL");
1627 if (str && strcmp (str, "1") == 0) return 1;
1631 static int test_equal_2 (void)
1633 if (test_equal_2_skip ()) {
1634 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_2");
1638 /* InitBasicFS for test_equal_2: create ext2 on /dev/sda1 */
1640 char device[] = "/dev/sda";
1641 device[5] = devchar;
1644 r = guestfs_blockdev_setrw (g, device);
1651 r = guestfs_umount_all (g);
1658 r = guestfs_lvm_remove_all (g);
1663 char device[] = "/dev/sda";
1664 device[5] = devchar;
1665 char lines_0[] = ",";
1672 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1677 char fstype[] = "ext2";
1678 char device[] = "/dev/sda1";
1679 device[5] = devchar;
1682 r = guestfs_mkfs (g, fstype, device);
1687 char device[] = "/dev/sda1";
1688 device[5] = devchar;
1689 char mountpoint[] = "/";
1692 r = guestfs_mount (g, device, mountpoint);
1696 /* TestLastFail for equal (2) */
1698 char file1[] = "/file1";
1699 char file2[] = "/file2";
1702 r = guestfs_equal (g, file1, file2);
1709 static int test_ping_daemon_0_skip (void)
1713 str = getenv ("SKIP_TEST_PING_DAEMON_0");
1714 if (str && strcmp (str, "1") == 0) return 1;
1715 str = getenv ("SKIP_TEST_PING_DAEMON");
1716 if (str && strcmp (str, "1") == 0) return 1;
1720 static int test_ping_daemon_0 (void)
1722 if (test_ping_daemon_0_skip ()) {
1723 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ping_daemon_0");
1727 /* InitNone|InitEmpty for test_ping_daemon_0 */
1729 char device[] = "/dev/sda";
1730 device[5] = devchar;
1733 r = guestfs_blockdev_setrw (g, device);
1740 r = guestfs_umount_all (g);
1747 r = guestfs_lvm_remove_all (g);
1751 /* TestRun for ping_daemon (0) */
1755 r = guestfs_ping_daemon (g);
1762 static int test_dmesg_0_skip (void)
1766 str = getenv ("SKIP_TEST_DMESG_0");
1767 if (str && strcmp (str, "1") == 0) return 1;
1768 str = getenv ("SKIP_TEST_DMESG");
1769 if (str && strcmp (str, "1") == 0) return 1;
1773 static int test_dmesg_0 (void)
1775 if (test_dmesg_0_skip ()) {
1776 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_dmesg_0");
1780 /* InitNone|InitEmpty for test_dmesg_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 dmesg (0) */
1808 r = guestfs_dmesg (g);
1816 static int test_drop_caches_0_skip (void)
1820 str = getenv ("SKIP_TEST_DROP_CACHES_0");
1821 if (str && strcmp (str, "1") == 0) return 1;
1822 str = getenv ("SKIP_TEST_DROP_CACHES");
1823 if (str && strcmp (str, "1") == 0) return 1;
1827 static int test_drop_caches_0 (void)
1829 if (test_drop_caches_0_skip ()) {
1830 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_drop_caches_0");
1834 /* InitNone|InitEmpty for test_drop_caches_0 */
1836 char device[] = "/dev/sda";
1837 device[5] = devchar;
1840 r = guestfs_blockdev_setrw (g, device);
1847 r = guestfs_umount_all (g);
1854 r = guestfs_lvm_remove_all (g);
1858 /* TestRun for drop_caches (0) */
1862 r = guestfs_drop_caches (g, 3);
1869 static int test_mv_0_skip (void)
1873 str = getenv ("SKIP_TEST_MV_0");
1874 if (str && strcmp (str, "1") == 0) return 1;
1875 str = getenv ("SKIP_TEST_MV");
1876 if (str && strcmp (str, "1") == 0) return 1;
1880 static int test_mv_0 (void)
1882 if (test_mv_0_skip ()) {
1883 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_0");
1887 /* InitBasicFS for test_mv_0: create ext2 on /dev/sda1 */
1889 char device[] = "/dev/sda";
1890 device[5] = devchar;
1893 r = guestfs_blockdev_setrw (g, device);
1900 r = guestfs_umount_all (g);
1907 r = guestfs_lvm_remove_all (g);
1912 char device[] = "/dev/sda";
1913 device[5] = devchar;
1914 char lines_0[] = ",";
1921 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1926 char fstype[] = "ext2";
1927 char device[] = "/dev/sda1";
1928 device[5] = devchar;
1931 r = guestfs_mkfs (g, fstype, device);
1936 char device[] = "/dev/sda1";
1937 device[5] = devchar;
1938 char mountpoint[] = "/";
1941 r = guestfs_mount (g, device, mountpoint);
1945 /* TestOutput for mv (0) */
1946 char expected[] = "file content";
1948 char path[] = "/old";
1949 char content[] = "file content";
1952 r = guestfs_write_file (g, path, content, 0);
1957 char src[] = "/old";
1958 char dest[] = "/new";
1961 r = guestfs_mv (g, src, dest);
1966 char path[] = "/new";
1969 r = guestfs_cat (g, path);
1972 if (strcmp (r, expected) != 0) {
1973 fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
1981 static int test_mv_1_skip (void)
1985 str = getenv ("SKIP_TEST_MV_1");
1986 if (str && strcmp (str, "1") == 0) return 1;
1987 str = getenv ("SKIP_TEST_MV");
1988 if (str && strcmp (str, "1") == 0) return 1;
1992 static int test_mv_1 (void)
1994 if (test_mv_1_skip ()) {
1995 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_1");
1999 /* InitBasicFS for test_mv_1: create ext2 on /dev/sda1 */
2001 char device[] = "/dev/sda";
2002 device[5] = devchar;
2005 r = guestfs_blockdev_setrw (g, device);
2012 r = guestfs_umount_all (g);
2019 r = guestfs_lvm_remove_all (g);
2024 char device[] = "/dev/sda";
2025 device[5] = devchar;
2026 char lines_0[] = ",";
2033 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2038 char fstype[] = "ext2";
2039 char device[] = "/dev/sda1";
2040 device[5] = devchar;
2043 r = guestfs_mkfs (g, fstype, device);
2048 char device[] = "/dev/sda1";
2049 device[5] = devchar;
2050 char mountpoint[] = "/";
2053 r = guestfs_mount (g, device, mountpoint);
2057 /* TestOutputFalse for mv (1) */
2059 char path[] = "/old";
2060 char content[] = "file content";
2063 r = guestfs_write_file (g, path, content, 0);
2068 char src[] = "/old";
2069 char dest[] = "/new";
2072 r = guestfs_mv (g, src, dest);
2077 char path[] = "/old";
2080 r = guestfs_is_file (g, path);
2084 fprintf (stderr, "test_mv_1: expected false, got true\n");
2091 static int test_cp_a_0_skip (void)
2095 str = getenv ("SKIP_TEST_CP_A_0");
2096 if (str && strcmp (str, "1") == 0) return 1;
2097 str = getenv ("SKIP_TEST_CP_A");
2098 if (str && strcmp (str, "1") == 0) return 1;
2102 static int test_cp_a_0 (void)
2104 if (test_cp_a_0_skip ()) {
2105 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_a_0");
2109 /* InitBasicFS for test_cp_a_0: create ext2 on /dev/sda1 */
2111 char device[] = "/dev/sda";
2112 device[5] = devchar;
2115 r = guestfs_blockdev_setrw (g, device);
2122 r = guestfs_umount_all (g);
2129 r = guestfs_lvm_remove_all (g);
2134 char device[] = "/dev/sda";
2135 device[5] = devchar;
2136 char lines_0[] = ",";
2143 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2148 char fstype[] = "ext2";
2149 char device[] = "/dev/sda1";
2150 device[5] = devchar;
2153 r = guestfs_mkfs (g, fstype, device);
2158 char device[] = "/dev/sda1";
2159 device[5] = devchar;
2160 char mountpoint[] = "/";
2163 r = guestfs_mount (g, device, mountpoint);
2167 /* TestOutput for cp_a (0) */
2168 char expected[] = "file content";
2170 char path[] = "/olddir";
2173 r = guestfs_mkdir (g, path);
2178 char path[] = "/newdir";
2181 r = guestfs_mkdir (g, path);
2186 char path[] = "/olddir/file";
2187 char content[] = "file content";
2190 r = guestfs_write_file (g, path, content, 0);
2195 char src[] = "/olddir";
2196 char dest[] = "/newdir";
2199 r = guestfs_cp_a (g, src, dest);
2204 char path[] = "/newdir/olddir/file";
2207 r = guestfs_cat (g, path);
2210 if (strcmp (r, expected) != 0) {
2211 fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
2219 static int test_cp_0_skip (void)
2223 str = getenv ("SKIP_TEST_CP_0");
2224 if (str && strcmp (str, "1") == 0) return 1;
2225 str = getenv ("SKIP_TEST_CP");
2226 if (str && strcmp (str, "1") == 0) return 1;
2230 static int test_cp_0 (void)
2232 if (test_cp_0_skip ()) {
2233 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_0");
2237 /* InitBasicFS for test_cp_0: create ext2 on /dev/sda1 */
2239 char device[] = "/dev/sda";
2240 device[5] = devchar;
2243 r = guestfs_blockdev_setrw (g, device);
2250 r = guestfs_umount_all (g);
2257 r = guestfs_lvm_remove_all (g);
2262 char device[] = "/dev/sda";
2263 device[5] = devchar;
2264 char lines_0[] = ",";
2271 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2276 char fstype[] = "ext2";
2277 char device[] = "/dev/sda1";
2278 device[5] = devchar;
2281 r = guestfs_mkfs (g, fstype, device);
2286 char device[] = "/dev/sda1";
2287 device[5] = devchar;
2288 char mountpoint[] = "/";
2291 r = guestfs_mount (g, device, mountpoint);
2295 /* TestOutput for cp (0) */
2296 char expected[] = "file content";
2298 char path[] = "/old";
2299 char content[] = "file content";
2302 r = guestfs_write_file (g, path, content, 0);
2307 char src[] = "/old";
2308 char dest[] = "/new";
2311 r = guestfs_cp (g, src, dest);
2316 char path[] = "/new";
2319 r = guestfs_cat (g, path);
2322 if (strcmp (r, expected) != 0) {
2323 fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
2331 static int test_cp_1_skip (void)
2335 str = getenv ("SKIP_TEST_CP_1");
2336 if (str && strcmp (str, "1") == 0) return 1;
2337 str = getenv ("SKIP_TEST_CP");
2338 if (str && strcmp (str, "1") == 0) return 1;
2342 static int test_cp_1 (void)
2344 if (test_cp_1_skip ()) {
2345 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_1");
2349 /* InitBasicFS for test_cp_1: create ext2 on /dev/sda1 */
2351 char device[] = "/dev/sda";
2352 device[5] = devchar;
2355 r = guestfs_blockdev_setrw (g, device);
2362 r = guestfs_umount_all (g);
2369 r = guestfs_lvm_remove_all (g);
2374 char device[] = "/dev/sda";
2375 device[5] = devchar;
2376 char lines_0[] = ",";
2383 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2388 char fstype[] = "ext2";
2389 char device[] = "/dev/sda1";
2390 device[5] = devchar;
2393 r = guestfs_mkfs (g, fstype, device);
2398 char device[] = "/dev/sda1";
2399 device[5] = devchar;
2400 char mountpoint[] = "/";
2403 r = guestfs_mount (g, device, mountpoint);
2407 /* TestOutputTrue for cp (1) */
2409 char path[] = "/old";
2410 char content[] = "file content";
2413 r = guestfs_write_file (g, path, content, 0);
2418 char src[] = "/old";
2419 char dest[] = "/new";
2422 r = guestfs_cp (g, src, dest);
2427 char path[] = "/old";
2430 r = guestfs_is_file (g, path);
2434 fprintf (stderr, "test_cp_1: expected true, got false\n");
2441 static int test_cp_2_skip (void)
2445 str = getenv ("SKIP_TEST_CP_2");
2446 if (str && strcmp (str, "1") == 0) return 1;
2447 str = getenv ("SKIP_TEST_CP");
2448 if (str && strcmp (str, "1") == 0) return 1;
2452 static int test_cp_2 (void)
2454 if (test_cp_2_skip ()) {
2455 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_2");
2459 /* InitBasicFS for test_cp_2: create ext2 on /dev/sda1 */
2461 char device[] = "/dev/sda";
2462 device[5] = devchar;
2465 r = guestfs_blockdev_setrw (g, device);
2472 r = guestfs_umount_all (g);
2479 r = guestfs_lvm_remove_all (g);
2484 char device[] = "/dev/sda";
2485 device[5] = devchar;
2486 char lines_0[] = ",";
2493 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2498 char fstype[] = "ext2";
2499 char device[] = "/dev/sda1";
2500 device[5] = devchar;
2503 r = guestfs_mkfs (g, fstype, device);
2508 char device[] = "/dev/sda1";
2509 device[5] = devchar;
2510 char mountpoint[] = "/";
2513 r = guestfs_mount (g, device, mountpoint);
2517 /* TestOutput for cp (2) */
2518 char expected[] = "file content";
2520 char path[] = "/old";
2521 char content[] = "file content";
2524 r = guestfs_write_file (g, path, content, 0);
2529 char path[] = "/dir";
2532 r = guestfs_mkdir (g, path);
2537 char src[] = "/old";
2538 char dest[] = "/dir/new";
2541 r = guestfs_cp (g, src, dest);
2546 char path[] = "/dir/new";
2549 r = guestfs_cat (g, path);
2552 if (strcmp (r, expected) != 0) {
2553 fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
2561 static int test_grub_install_0_skip (void)
2565 str = getenv ("SKIP_TEST_GRUB_INSTALL_0");
2566 if (str && strcmp (str, "1") == 0) return 1;
2567 str = getenv ("SKIP_TEST_GRUB_INSTALL");
2568 if (str && strcmp (str, "1") == 0) return 1;
2572 static int test_grub_install_0 (void)
2574 if (test_grub_install_0_skip ()) {
2575 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_grub_install_0");
2579 /* InitBasicFS for test_grub_install_0: create ext2 on /dev/sda1 */
2581 char device[] = "/dev/sda";
2582 device[5] = devchar;
2585 r = guestfs_blockdev_setrw (g, device);
2592 r = guestfs_umount_all (g);
2599 r = guestfs_lvm_remove_all (g);
2604 char device[] = "/dev/sda";
2605 device[5] = devchar;
2606 char lines_0[] = ",";
2613 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2618 char fstype[] = "ext2";
2619 char device[] = "/dev/sda1";
2620 device[5] = devchar;
2623 r = guestfs_mkfs (g, fstype, device);
2628 char device[] = "/dev/sda1";
2629 device[5] = devchar;
2630 char mountpoint[] = "/";
2633 r = guestfs_mount (g, device, mountpoint);
2637 /* TestOutputTrue for grub_install (0) */
2640 char device[] = "/dev/sda1";
2641 device[5] = devchar;
2644 r = guestfs_grub_install (g, root, device);
2649 char path[] = "/boot";
2652 r = guestfs_is_dir (g, path);
2656 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
2663 static int test_zero_0_skip (void)
2667 str = getenv ("SKIP_TEST_ZERO_0");
2668 if (str && strcmp (str, "1") == 0) return 1;
2669 str = getenv ("SKIP_TEST_ZERO");
2670 if (str && strcmp (str, "1") == 0) return 1;
2674 static int test_zero_0 (void)
2676 if (test_zero_0_skip ()) {
2677 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zero_0");
2681 /* InitBasicFS for test_zero_0: create ext2 on /dev/sda1 */
2683 char device[] = "/dev/sda";
2684 device[5] = devchar;
2687 r = guestfs_blockdev_setrw (g, device);
2694 r = guestfs_umount_all (g);
2701 r = guestfs_lvm_remove_all (g);
2706 char device[] = "/dev/sda";
2707 device[5] = devchar;
2708 char lines_0[] = ",";
2715 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2720 char fstype[] = "ext2";
2721 char device[] = "/dev/sda1";
2722 device[5] = devchar;
2725 r = guestfs_mkfs (g, fstype, device);
2730 char device[] = "/dev/sda1";
2731 device[5] = devchar;
2732 char mountpoint[] = "/";
2735 r = guestfs_mount (g, device, mountpoint);
2739 /* TestOutput for zero (0) */
2740 char expected[] = "data";
2742 char pathordevice[] = "/dev/sda1";
2743 pathordevice[5] = devchar;
2746 r = guestfs_umount (g, pathordevice);
2751 char device[] = "/dev/sda1";
2752 device[5] = devchar;
2755 r = guestfs_zero (g, device);
2760 char path[] = "/dev/sda1";
2764 r = guestfs_file (g, path);
2767 if (strcmp (r, expected) != 0) {
2768 fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
2776 static int test_fsck_0_skip (void)
2780 str = getenv ("SKIP_TEST_FSCK_0");
2781 if (str && strcmp (str, "1") == 0) return 1;
2782 str = getenv ("SKIP_TEST_FSCK");
2783 if (str && strcmp (str, "1") == 0) return 1;
2787 static int test_fsck_0 (void)
2789 if (test_fsck_0_skip ()) {
2790 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_0");
2794 /* InitBasicFS for test_fsck_0: create ext2 on /dev/sda1 */
2796 char device[] = "/dev/sda";
2797 device[5] = devchar;
2800 r = guestfs_blockdev_setrw (g, device);
2807 r = guestfs_umount_all (g);
2814 r = guestfs_lvm_remove_all (g);
2819 char device[] = "/dev/sda";
2820 device[5] = devchar;
2821 char lines_0[] = ",";
2828 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2833 char fstype[] = "ext2";
2834 char device[] = "/dev/sda1";
2835 device[5] = devchar;
2838 r = guestfs_mkfs (g, fstype, device);
2843 char device[] = "/dev/sda1";
2844 device[5] = devchar;
2845 char mountpoint[] = "/";
2848 r = guestfs_mount (g, device, mountpoint);
2852 /* TestOutputInt for fsck (0) */
2854 char pathordevice[] = "/dev/sda1";
2855 pathordevice[5] = devchar;
2858 r = guestfs_umount (g, pathordevice);
2863 char fstype[] = "ext2";
2864 char device[] = "/dev/sda1";
2865 device[5] = devchar;
2868 r = guestfs_fsck (g, fstype, device);
2872 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
2879 static int test_fsck_1_skip (void)
2883 str = getenv ("SKIP_TEST_FSCK_1");
2884 if (str && strcmp (str, "1") == 0) return 1;
2885 str = getenv ("SKIP_TEST_FSCK");
2886 if (str && strcmp (str, "1") == 0) return 1;
2890 static int test_fsck_1 (void)
2892 if (test_fsck_1_skip ()) {
2893 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_1");
2897 /* InitBasicFS for test_fsck_1: create ext2 on /dev/sda1 */
2899 char device[] = "/dev/sda";
2900 device[5] = devchar;
2903 r = guestfs_blockdev_setrw (g, device);
2910 r = guestfs_umount_all (g);
2917 r = guestfs_lvm_remove_all (g);
2922 char device[] = "/dev/sda";
2923 device[5] = devchar;
2924 char lines_0[] = ",";
2931 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2936 char fstype[] = "ext2";
2937 char device[] = "/dev/sda1";
2938 device[5] = devchar;
2941 r = guestfs_mkfs (g, fstype, device);
2946 char device[] = "/dev/sda1";
2947 device[5] = devchar;
2948 char mountpoint[] = "/";
2951 r = guestfs_mount (g, device, mountpoint);
2955 /* TestOutputInt for fsck (1) */
2957 char pathordevice[] = "/dev/sda1";
2958 pathordevice[5] = devchar;
2961 r = guestfs_umount (g, pathordevice);
2966 char device[] = "/dev/sda1";
2967 device[5] = devchar;
2970 r = guestfs_zero (g, device);
2975 char fstype[] = "ext2";
2976 char device[] = "/dev/sda1";
2977 device[5] = devchar;
2980 r = guestfs_fsck (g, fstype, device);
2984 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
2991 static int test_set_e2uuid_0_skip (void)
2995 str = getenv ("SKIP_TEST_SET_E2UUID_0");
2996 if (str && strcmp (str, "1") == 0) return 1;
2997 str = getenv ("SKIP_TEST_SET_E2UUID");
2998 if (str && strcmp (str, "1") == 0) return 1;
3002 static int test_set_e2uuid_0 (void)
3004 if (test_set_e2uuid_0_skip ()) {
3005 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_0");
3009 /* InitBasicFS for test_set_e2uuid_0: create ext2 on /dev/sda1 */
3011 char device[] = "/dev/sda";
3012 device[5] = devchar;
3015 r = guestfs_blockdev_setrw (g, device);
3022 r = guestfs_umount_all (g);
3029 r = guestfs_lvm_remove_all (g);
3034 char device[] = "/dev/sda";
3035 device[5] = devchar;
3036 char lines_0[] = ",";
3043 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3048 char fstype[] = "ext2";
3049 char device[] = "/dev/sda1";
3050 device[5] = devchar;
3053 r = guestfs_mkfs (g, fstype, device);
3058 char device[] = "/dev/sda1";
3059 device[5] = devchar;
3060 char mountpoint[] = "/";
3063 r = guestfs_mount (g, device, mountpoint);
3067 /* TestOutput for set_e2uuid (0) */
3068 char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
3070 char device[] = "/dev/sda1";
3071 device[5] = devchar;
3072 char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
3075 r = guestfs_set_e2uuid (g, device, uuid);
3080 char device[] = "/dev/sda1";
3081 device[5] = devchar;
3084 r = guestfs_get_e2uuid (g, device);
3087 if (strcmp (r, expected) != 0) {
3088 fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
3096 static int test_set_e2uuid_1_skip (void)
3100 str = getenv ("SKIP_TEST_SET_E2UUID_1");
3101 if (str && strcmp (str, "1") == 0) return 1;
3102 str = getenv ("SKIP_TEST_SET_E2UUID");
3103 if (str && strcmp (str, "1") == 0) return 1;
3107 static int test_set_e2uuid_1 (void)
3109 if (test_set_e2uuid_1_skip ()) {
3110 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_1");
3114 /* InitBasicFS for test_set_e2uuid_1: create ext2 on /dev/sda1 */
3116 char device[] = "/dev/sda";
3117 device[5] = devchar;
3120 r = guestfs_blockdev_setrw (g, device);
3127 r = guestfs_umount_all (g);
3134 r = guestfs_lvm_remove_all (g);
3139 char device[] = "/dev/sda";
3140 device[5] = devchar;
3141 char lines_0[] = ",";
3148 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3153 char fstype[] = "ext2";
3154 char device[] = "/dev/sda1";
3155 device[5] = devchar;
3158 r = guestfs_mkfs (g, fstype, device);
3163 char device[] = "/dev/sda1";
3164 device[5] = devchar;
3165 char mountpoint[] = "/";
3168 r = guestfs_mount (g, device, mountpoint);
3172 /* TestOutput for set_e2uuid (1) */
3173 char expected[] = "";
3175 char device[] = "/dev/sda1";
3176 device[5] = devchar;
3177 char uuid[] = "clear";
3180 r = guestfs_set_e2uuid (g, device, uuid);
3185 char device[] = "/dev/sda1";
3186 device[5] = devchar;
3189 r = guestfs_get_e2uuid (g, device);
3192 if (strcmp (r, expected) != 0) {
3193 fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
3201 static int test_set_e2uuid_2_skip (void)
3205 str = getenv ("SKIP_TEST_SET_E2UUID_2");
3206 if (str && strcmp (str, "1") == 0) return 1;
3207 str = getenv ("SKIP_TEST_SET_E2UUID");
3208 if (str && strcmp (str, "1") == 0) return 1;
3212 static int test_set_e2uuid_2 (void)
3214 if (test_set_e2uuid_2_skip ()) {
3215 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_2");
3219 /* InitBasicFS for test_set_e2uuid_2: create ext2 on /dev/sda1 */
3221 char device[] = "/dev/sda";
3222 device[5] = devchar;
3225 r = guestfs_blockdev_setrw (g, device);
3232 r = guestfs_umount_all (g);
3239 r = guestfs_lvm_remove_all (g);
3244 char device[] = "/dev/sda";
3245 device[5] = devchar;
3246 char lines_0[] = ",";
3253 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3258 char fstype[] = "ext2";
3259 char device[] = "/dev/sda1";
3260 device[5] = devchar;
3263 r = guestfs_mkfs (g, fstype, device);
3268 char device[] = "/dev/sda1";
3269 device[5] = devchar;
3270 char mountpoint[] = "/";
3273 r = guestfs_mount (g, device, mountpoint);
3277 /* TestRun for set_e2uuid (2) */
3279 char device[] = "/dev/sda1";
3280 device[5] = devchar;
3281 char uuid[] = "random";
3284 r = guestfs_set_e2uuid (g, device, uuid);
3291 static int test_set_e2uuid_3_skip (void)
3295 str = getenv ("SKIP_TEST_SET_E2UUID_3");
3296 if (str && strcmp (str, "1") == 0) return 1;
3297 str = getenv ("SKIP_TEST_SET_E2UUID");
3298 if (str && strcmp (str, "1") == 0) return 1;
3302 static int test_set_e2uuid_3 (void)
3304 if (test_set_e2uuid_3_skip ()) {
3305 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_3");
3309 /* InitBasicFS for test_set_e2uuid_3: create ext2 on /dev/sda1 */
3311 char device[] = "/dev/sda";
3312 device[5] = devchar;
3315 r = guestfs_blockdev_setrw (g, device);
3322 r = guestfs_umount_all (g);
3329 r = guestfs_lvm_remove_all (g);
3334 char device[] = "/dev/sda";
3335 device[5] = devchar;
3336 char lines_0[] = ",";
3343 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3348 char fstype[] = "ext2";
3349 char device[] = "/dev/sda1";
3350 device[5] = devchar;
3353 r = guestfs_mkfs (g, fstype, device);
3358 char device[] = "/dev/sda1";
3359 device[5] = devchar;
3360 char mountpoint[] = "/";
3363 r = guestfs_mount (g, device, mountpoint);
3367 /* TestRun for set_e2uuid (3) */
3369 char device[] = "/dev/sda1";
3370 device[5] = devchar;
3371 char uuid[] = "time";
3374 r = guestfs_set_e2uuid (g, device, uuid);
3381 static int test_set_e2label_0_skip (void)
3385 str = getenv ("SKIP_TEST_SET_E2LABEL_0");
3386 if (str && strcmp (str, "1") == 0) return 1;
3387 str = getenv ("SKIP_TEST_SET_E2LABEL");
3388 if (str && strcmp (str, "1") == 0) return 1;
3392 static int test_set_e2label_0 (void)
3394 if (test_set_e2label_0_skip ()) {
3395 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2label_0");
3399 /* InitBasicFS for test_set_e2label_0: create ext2 on /dev/sda1 */
3401 char device[] = "/dev/sda";
3402 device[5] = devchar;
3405 r = guestfs_blockdev_setrw (g, device);
3412 r = guestfs_umount_all (g);
3419 r = guestfs_lvm_remove_all (g);
3424 char device[] = "/dev/sda";
3425 device[5] = devchar;
3426 char lines_0[] = ",";
3433 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3438 char fstype[] = "ext2";
3439 char device[] = "/dev/sda1";
3440 device[5] = devchar;
3443 r = guestfs_mkfs (g, fstype, device);
3448 char device[] = "/dev/sda1";
3449 device[5] = devchar;
3450 char mountpoint[] = "/";
3453 r = guestfs_mount (g, device, mountpoint);
3457 /* TestOutput for set_e2label (0) */
3458 char expected[] = "testlabel";
3460 char device[] = "/dev/sda1";
3461 device[5] = devchar;
3462 char label[] = "testlabel";
3465 r = guestfs_set_e2label (g, device, label);
3470 char device[] = "/dev/sda1";
3471 device[5] = devchar;
3474 r = guestfs_get_e2label (g, device);
3477 if (strcmp (r, expected) != 0) {
3478 fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
3486 static int test_pvremove_0_skip (void)
3490 str = getenv ("SKIP_TEST_PVREMOVE_0");
3491 if (str && strcmp (str, "1") == 0) return 1;
3492 str = getenv ("SKIP_TEST_PVREMOVE");
3493 if (str && strcmp (str, "1") == 0) return 1;
3497 static int test_pvremove_0 (void)
3499 if (test_pvremove_0_skip ()) {
3500 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_0");
3504 /* InitNone|InitEmpty for test_pvremove_0 */
3506 char device[] = "/dev/sda";
3507 device[5] = devchar;
3510 r = guestfs_blockdev_setrw (g, device);
3517 r = guestfs_umount_all (g);
3524 r = guestfs_lvm_remove_all (g);
3528 /* TestOutputList for pvremove (0) */
3530 char device[] = "/dev/sda";
3531 device[5] = devchar;
3532 char lines_0[] = ",";
3539 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3544 char device[] = "/dev/sda1";
3545 device[5] = devchar;
3548 r = guestfs_pvcreate (g, device);
3553 char volgroup[] = "VG";
3554 char physvols_0[] = "/dev/sda1";
3555 physvols_0[5] = devchar;
3556 char *physvols[] = {
3562 r = guestfs_vgcreate (g, volgroup, physvols);
3567 char logvol[] = "LV1";
3568 char volgroup[] = "VG";
3571 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3576 char logvol[] = "LV2";
3577 char volgroup[] = "VG";
3580 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3585 char vgname[] = "VG";
3588 r = guestfs_vgremove (g, vgname);
3593 char device[] = "/dev/sda1";
3594 device[5] = devchar;
3597 r = guestfs_pvremove (g, device);
3605 r = guestfs_lvs (g);
3609 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
3613 for (i = 0; r[i] != NULL; ++i)
3620 static int test_pvremove_1_skip (void)
3624 str = getenv ("SKIP_TEST_PVREMOVE_1");
3625 if (str && strcmp (str, "1") == 0) return 1;
3626 str = getenv ("SKIP_TEST_PVREMOVE");
3627 if (str && strcmp (str, "1") == 0) return 1;
3631 static int test_pvremove_1 (void)
3633 if (test_pvremove_1_skip ()) {
3634 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_1");
3638 /* InitNone|InitEmpty for test_pvremove_1 */
3640 char device[] = "/dev/sda";
3641 device[5] = devchar;
3644 r = guestfs_blockdev_setrw (g, device);
3651 r = guestfs_umount_all (g);
3658 r = guestfs_lvm_remove_all (g);
3662 /* TestOutputList for pvremove (1) */
3664 char device[] = "/dev/sda";
3665 device[5] = devchar;
3666 char lines_0[] = ",";
3673 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3678 char device[] = "/dev/sda1";
3679 device[5] = devchar;
3682 r = guestfs_pvcreate (g, device);
3687 char volgroup[] = "VG";
3688 char physvols_0[] = "/dev/sda1";
3689 physvols_0[5] = devchar;
3690 char *physvols[] = {
3696 r = guestfs_vgcreate (g, volgroup, physvols);
3701 char logvol[] = "LV1";
3702 char volgroup[] = "VG";
3705 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3710 char logvol[] = "LV2";
3711 char volgroup[] = "VG";
3714 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3719 char vgname[] = "VG";
3722 r = guestfs_vgremove (g, vgname);
3727 char device[] = "/dev/sda1";
3728 device[5] = devchar;
3731 r = guestfs_pvremove (g, device);
3739 r = guestfs_vgs (g);
3743 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
3747 for (i = 0; r[i] != NULL; ++i)
3754 static int test_pvremove_2_skip (void)
3758 str = getenv ("SKIP_TEST_PVREMOVE_2");
3759 if (str && strcmp (str, "1") == 0) return 1;
3760 str = getenv ("SKIP_TEST_PVREMOVE");
3761 if (str && strcmp (str, "1") == 0) return 1;
3765 static int test_pvremove_2 (void)
3767 if (test_pvremove_2_skip ()) {
3768 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_2");
3772 /* InitNone|InitEmpty for test_pvremove_2 */
3774 char device[] = "/dev/sda";
3775 device[5] = devchar;
3778 r = guestfs_blockdev_setrw (g, device);
3785 r = guestfs_umount_all (g);
3792 r = guestfs_lvm_remove_all (g);
3796 /* TestOutputList for pvremove (2) */
3798 char device[] = "/dev/sda";
3799 device[5] = devchar;
3800 char lines_0[] = ",";
3807 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3812 char device[] = "/dev/sda1";
3813 device[5] = devchar;
3816 r = guestfs_pvcreate (g, device);
3821 char volgroup[] = "VG";
3822 char physvols_0[] = "/dev/sda1";
3823 physvols_0[5] = devchar;
3824 char *physvols[] = {
3830 r = guestfs_vgcreate (g, volgroup, physvols);
3835 char logvol[] = "LV1";
3836 char volgroup[] = "VG";
3839 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3844 char logvol[] = "LV2";
3845 char volgroup[] = "VG";
3848 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3853 char vgname[] = "VG";
3856 r = guestfs_vgremove (g, vgname);
3861 char device[] = "/dev/sda1";
3862 device[5] = devchar;
3865 r = guestfs_pvremove (g, device);
3873 r = guestfs_pvs (g);
3877 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
3881 for (i = 0; r[i] != NULL; ++i)
3888 static int test_vgremove_0_skip (void)
3892 str = getenv ("SKIP_TEST_VGREMOVE_0");
3893 if (str && strcmp (str, "1") == 0) return 1;
3894 str = getenv ("SKIP_TEST_VGREMOVE");
3895 if (str && strcmp (str, "1") == 0) return 1;
3899 static int test_vgremove_0 (void)
3901 if (test_vgremove_0_skip ()) {
3902 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_0");
3906 /* InitNone|InitEmpty for test_vgremove_0 */
3908 char device[] = "/dev/sda";
3909 device[5] = devchar;
3912 r = guestfs_blockdev_setrw (g, device);
3919 r = guestfs_umount_all (g);
3926 r = guestfs_lvm_remove_all (g);
3930 /* TestOutputList for vgremove (0) */
3932 char device[] = "/dev/sda";
3933 device[5] = devchar;
3934 char lines_0[] = ",";
3941 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3946 char device[] = "/dev/sda1";
3947 device[5] = devchar;
3950 r = guestfs_pvcreate (g, device);
3955 char volgroup[] = "VG";
3956 char physvols_0[] = "/dev/sda1";
3957 physvols_0[5] = devchar;
3958 char *physvols[] = {
3964 r = guestfs_vgcreate (g, volgroup, physvols);
3969 char logvol[] = "LV1";
3970 char volgroup[] = "VG";
3973 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3978 char logvol[] = "LV2";
3979 char volgroup[] = "VG";
3982 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3987 char vgname[] = "VG";
3990 r = guestfs_vgremove (g, vgname);
3998 r = guestfs_lvs (g);
4002 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
4006 for (i = 0; r[i] != NULL; ++i)
4013 static int test_vgremove_1_skip (void)
4017 str = getenv ("SKIP_TEST_VGREMOVE_1");
4018 if (str && strcmp (str, "1") == 0) return 1;
4019 str = getenv ("SKIP_TEST_VGREMOVE");
4020 if (str && strcmp (str, "1") == 0) return 1;
4024 static int test_vgremove_1 (void)
4026 if (test_vgremove_1_skip ()) {
4027 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_1");
4031 /* InitNone|InitEmpty for test_vgremove_1 */
4033 char device[] = "/dev/sda";
4034 device[5] = devchar;
4037 r = guestfs_blockdev_setrw (g, device);
4044 r = guestfs_umount_all (g);
4051 r = guestfs_lvm_remove_all (g);
4055 /* TestOutputList for vgremove (1) */
4057 char device[] = "/dev/sda";
4058 device[5] = devchar;
4059 char lines_0[] = ",";
4066 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4071 char device[] = "/dev/sda1";
4072 device[5] = devchar;
4075 r = guestfs_pvcreate (g, device);
4080 char volgroup[] = "VG";
4081 char physvols_0[] = "/dev/sda1";
4082 physvols_0[5] = devchar;
4083 char *physvols[] = {
4089 r = guestfs_vgcreate (g, volgroup, physvols);
4094 char logvol[] = "LV1";
4095 char volgroup[] = "VG";
4098 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4103 char logvol[] = "LV2";
4104 char volgroup[] = "VG";
4107 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4112 char vgname[] = "VG";
4115 r = guestfs_vgremove (g, vgname);
4123 r = guestfs_vgs (g);
4127 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
4131 for (i = 0; r[i] != NULL; ++i)
4138 static int test_lvremove_0_skip (void)
4142 str = getenv ("SKIP_TEST_LVREMOVE_0");
4143 if (str && strcmp (str, "1") == 0) return 1;
4144 str = getenv ("SKIP_TEST_LVREMOVE");
4145 if (str && strcmp (str, "1") == 0) return 1;
4149 static int test_lvremove_0 (void)
4151 if (test_lvremove_0_skip ()) {
4152 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_0");
4156 /* InitNone|InitEmpty for test_lvremove_0 */
4158 char device[] = "/dev/sda";
4159 device[5] = devchar;
4162 r = guestfs_blockdev_setrw (g, device);
4169 r = guestfs_umount_all (g);
4176 r = guestfs_lvm_remove_all (g);
4180 /* TestOutputList for lvremove (0) */
4182 char device[] = "/dev/sda";
4183 device[5] = devchar;
4184 char lines_0[] = ",";
4191 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4196 char device[] = "/dev/sda1";
4197 device[5] = devchar;
4200 r = guestfs_pvcreate (g, device);
4205 char volgroup[] = "VG";
4206 char physvols_0[] = "/dev/sda1";
4207 physvols_0[5] = devchar;
4208 char *physvols[] = {
4214 r = guestfs_vgcreate (g, volgroup, physvols);
4219 char logvol[] = "LV1";
4220 char volgroup[] = "VG";
4223 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4228 char logvol[] = "LV2";
4229 char volgroup[] = "VG";
4232 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4237 char device[] = "/dev/VG/LV1";
4240 r = guestfs_lvremove (g, device);
4248 r = guestfs_lvs (g);
4252 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
4257 char expected[] = "/dev/VG/LV2";
4258 if (strcmp (r[0], expected) != 0) {
4259 fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
4264 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
4268 for (i = 0; r[i] != NULL; ++i)
4275 static int test_lvremove_1_skip (void)
4279 str = getenv ("SKIP_TEST_LVREMOVE_1");
4280 if (str && strcmp (str, "1") == 0) return 1;
4281 str = getenv ("SKIP_TEST_LVREMOVE");
4282 if (str && strcmp (str, "1") == 0) return 1;
4286 static int test_lvremove_1 (void)
4288 if (test_lvremove_1_skip ()) {
4289 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_1");
4293 /* InitNone|InitEmpty for test_lvremove_1 */
4295 char device[] = "/dev/sda";
4296 device[5] = devchar;
4299 r = guestfs_blockdev_setrw (g, device);
4306 r = guestfs_umount_all (g);
4313 r = guestfs_lvm_remove_all (g);
4317 /* TestOutputList for lvremove (1) */
4319 char device[] = "/dev/sda";
4320 device[5] = devchar;
4321 char lines_0[] = ",";
4328 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4333 char device[] = "/dev/sda1";
4334 device[5] = devchar;
4337 r = guestfs_pvcreate (g, device);
4342 char volgroup[] = "VG";
4343 char physvols_0[] = "/dev/sda1";
4344 physvols_0[5] = devchar;
4345 char *physvols[] = {
4351 r = guestfs_vgcreate (g, volgroup, physvols);
4356 char logvol[] = "LV1";
4357 char volgroup[] = "VG";
4360 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4365 char logvol[] = "LV2";
4366 char volgroup[] = "VG";
4369 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4374 char device[] = "/dev/VG";
4377 r = guestfs_lvremove (g, device);
4385 r = guestfs_lvs (g);
4389 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
4393 for (i = 0; r[i] != NULL; ++i)
4400 static int test_lvremove_2_skip (void)
4404 str = getenv ("SKIP_TEST_LVREMOVE_2");
4405 if (str && strcmp (str, "1") == 0) return 1;
4406 str = getenv ("SKIP_TEST_LVREMOVE");
4407 if (str && strcmp (str, "1") == 0) return 1;
4411 static int test_lvremove_2 (void)
4413 if (test_lvremove_2_skip ()) {
4414 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_2");
4418 /* InitNone|InitEmpty for test_lvremove_2 */
4420 char device[] = "/dev/sda";
4421 device[5] = devchar;
4424 r = guestfs_blockdev_setrw (g, device);
4431 r = guestfs_umount_all (g);
4438 r = guestfs_lvm_remove_all (g);
4442 /* TestOutputList for lvremove (2) */
4444 char device[] = "/dev/sda";
4445 device[5] = devchar;
4446 char lines_0[] = ",";
4453 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4458 char device[] = "/dev/sda1";
4459 device[5] = devchar;
4462 r = guestfs_pvcreate (g, device);
4467 char volgroup[] = "VG";
4468 char physvols_0[] = "/dev/sda1";
4469 physvols_0[5] = devchar;
4470 char *physvols[] = {
4476 r = guestfs_vgcreate (g, volgroup, physvols);
4481 char logvol[] = "LV1";
4482 char volgroup[] = "VG";
4485 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4490 char logvol[] = "LV2";
4491 char volgroup[] = "VG";
4494 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4499 char device[] = "/dev/VG";
4502 r = guestfs_lvremove (g, device);
4510 r = guestfs_vgs (g);
4514 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
4519 char expected[] = "VG";
4520 if (strcmp (r[0], expected) != 0) {
4521 fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
4526 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
4530 for (i = 0; r[i] != NULL; ++i)
4537 static int test_mount_ro_0_skip (void)
4541 str = getenv ("SKIP_TEST_MOUNT_RO_0");
4542 if (str && strcmp (str, "1") == 0) return 1;
4543 str = getenv ("SKIP_TEST_MOUNT_RO");
4544 if (str && strcmp (str, "1") == 0) return 1;
4548 static int test_mount_ro_0 (void)
4550 if (test_mount_ro_0_skip ()) {
4551 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_0");
4555 /* InitBasicFS for test_mount_ro_0: create ext2 on /dev/sda1 */
4557 char device[] = "/dev/sda";
4558 device[5] = devchar;
4561 r = guestfs_blockdev_setrw (g, device);
4568 r = guestfs_umount_all (g);
4575 r = guestfs_lvm_remove_all (g);
4580 char device[] = "/dev/sda";
4581 device[5] = devchar;
4582 char lines_0[] = ",";
4589 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4594 char fstype[] = "ext2";
4595 char device[] = "/dev/sda1";
4596 device[5] = devchar;
4599 r = guestfs_mkfs (g, fstype, device);
4604 char device[] = "/dev/sda1";
4605 device[5] = devchar;
4606 char mountpoint[] = "/";
4609 r = guestfs_mount (g, device, mountpoint);
4613 /* TestLastFail for mount_ro (0) */
4615 char pathordevice[] = "/";
4618 r = guestfs_umount (g, pathordevice);
4623 char device[] = "/dev/sda1";
4624 device[5] = devchar;
4625 char mountpoint[] = "/";
4628 r = guestfs_mount_ro (g, device, mountpoint);
4633 char path[] = "/new";
4636 r = guestfs_touch (g, path);
4643 static int test_mount_ro_1_skip (void)
4647 str = getenv ("SKIP_TEST_MOUNT_RO_1");
4648 if (str && strcmp (str, "1") == 0) return 1;
4649 str = getenv ("SKIP_TEST_MOUNT_RO");
4650 if (str && strcmp (str, "1") == 0) return 1;
4654 static int test_mount_ro_1 (void)
4656 if (test_mount_ro_1_skip ()) {
4657 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_1");
4661 /* InitBasicFS for test_mount_ro_1: create ext2 on /dev/sda1 */
4663 char device[] = "/dev/sda";
4664 device[5] = devchar;
4667 r = guestfs_blockdev_setrw (g, device);
4674 r = guestfs_umount_all (g);
4681 r = guestfs_lvm_remove_all (g);
4686 char device[] = "/dev/sda";
4687 device[5] = devchar;
4688 char lines_0[] = ",";
4695 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4700 char fstype[] = "ext2";
4701 char device[] = "/dev/sda1";
4702 device[5] = devchar;
4705 r = guestfs_mkfs (g, fstype, device);
4710 char device[] = "/dev/sda1";
4711 device[5] = devchar;
4712 char mountpoint[] = "/";
4715 r = guestfs_mount (g, device, mountpoint);
4719 /* TestOutput for mount_ro (1) */
4720 char expected[] = "data";
4722 char path[] = "/new";
4723 char content[] = "data";
4726 r = guestfs_write_file (g, path, content, 0);
4731 char pathordevice[] = "/";
4734 r = guestfs_umount (g, pathordevice);
4739 char device[] = "/dev/sda1";
4740 device[5] = devchar;
4741 char mountpoint[] = "/";
4744 r = guestfs_mount_ro (g, device, mountpoint);
4749 char path[] = "/new";
4752 r = guestfs_cat (g, path);
4755 if (strcmp (r, expected) != 0) {
4756 fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
4764 static int test_tgz_in_0_skip (void)
4768 str = getenv ("SKIP_TEST_TGZ_IN_0");
4769 if (str && strcmp (str, "1") == 0) return 1;
4770 str = getenv ("SKIP_TEST_TGZ_IN");
4771 if (str && strcmp (str, "1") == 0) return 1;
4775 static int test_tgz_in_0 (void)
4777 if (test_tgz_in_0_skip ()) {
4778 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tgz_in_0");
4782 /* InitBasicFS for test_tgz_in_0: create ext2 on /dev/sda1 */
4784 char device[] = "/dev/sda";
4785 device[5] = devchar;
4788 r = guestfs_blockdev_setrw (g, device);
4795 r = guestfs_umount_all (g);
4802 r = guestfs_lvm_remove_all (g);
4807 char device[] = "/dev/sda";
4808 device[5] = devchar;
4809 char lines_0[] = ",";
4816 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4821 char fstype[] = "ext2";
4822 char device[] = "/dev/sda1";
4823 device[5] = devchar;
4826 r = guestfs_mkfs (g, fstype, device);
4831 char device[] = "/dev/sda1";
4832 device[5] = devchar;
4833 char mountpoint[] = "/";
4836 r = guestfs_mount (g, device, mountpoint);
4840 /* TestOutput for tgz_in (0) */
4841 char expected[] = "hello\n";
4843 char directory[] = "/";
4846 r = guestfs_tgz_in (g, "../images/helloworld.tar.gz", directory);
4851 char path[] = "/hello";
4854 r = guestfs_cat (g, path);
4857 if (strcmp (r, expected) != 0) {
4858 fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
4866 static int test_tar_in_0_skip (void)
4870 str = getenv ("SKIP_TEST_TAR_IN_0");
4871 if (str && strcmp (str, "1") == 0) return 1;
4872 str = getenv ("SKIP_TEST_TAR_IN");
4873 if (str && strcmp (str, "1") == 0) return 1;
4877 static int test_tar_in_0 (void)
4879 if (test_tar_in_0_skip ()) {
4880 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tar_in_0");
4884 /* InitBasicFS for test_tar_in_0: create ext2 on /dev/sda1 */
4886 char device[] = "/dev/sda";
4887 device[5] = devchar;
4890 r = guestfs_blockdev_setrw (g, device);
4897 r = guestfs_umount_all (g);
4904 r = guestfs_lvm_remove_all (g);
4909 char device[] = "/dev/sda";
4910 device[5] = devchar;
4911 char lines_0[] = ",";
4918 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4923 char fstype[] = "ext2";
4924 char device[] = "/dev/sda1";
4925 device[5] = devchar;
4928 r = guestfs_mkfs (g, fstype, device);
4933 char device[] = "/dev/sda1";
4934 device[5] = devchar;
4935 char mountpoint[] = "/";
4938 r = guestfs_mount (g, device, mountpoint);
4942 /* TestOutput for tar_in (0) */
4943 char expected[] = "hello\n";
4945 char directory[] = "/";
4948 r = guestfs_tar_in (g, "../images/helloworld.tar", directory);
4953 char path[] = "/hello";
4956 r = guestfs_cat (g, path);
4959 if (strcmp (r, expected) != 0) {
4960 fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
4968 static int test_checksum_0_skip (void)
4972 str = getenv ("SKIP_TEST_CHECKSUM_0");
4973 if (str && strcmp (str, "1") == 0) return 1;
4974 str = getenv ("SKIP_TEST_CHECKSUM");
4975 if (str && strcmp (str, "1") == 0) return 1;
4979 static int test_checksum_0 (void)
4981 if (test_checksum_0_skip ()) {
4982 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_0");
4986 /* InitBasicFS for test_checksum_0: create ext2 on /dev/sda1 */
4988 char device[] = "/dev/sda";
4989 device[5] = devchar;
4992 r = guestfs_blockdev_setrw (g, device);
4999 r = guestfs_umount_all (g);
5006 r = guestfs_lvm_remove_all (g);
5011 char device[] = "/dev/sda";
5012 device[5] = devchar;
5013 char lines_0[] = ",";
5020 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5025 char fstype[] = "ext2";
5026 char device[] = "/dev/sda1";
5027 device[5] = devchar;
5030 r = guestfs_mkfs (g, fstype, device);
5035 char device[] = "/dev/sda1";
5036 device[5] = devchar;
5037 char mountpoint[] = "/";
5040 r = guestfs_mount (g, device, mountpoint);
5044 /* TestOutput for checksum (0) */
5045 char expected[] = "935282863";
5047 char path[] = "/new";
5048 char content[] = "test\n";
5051 r = guestfs_write_file (g, path, content, 0);
5056 char csumtype[] = "crc";
5057 char path[] = "/new";
5060 r = guestfs_checksum (g, csumtype, path);
5063 if (strcmp (r, expected) != 0) {
5064 fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
5072 static int test_checksum_1_skip (void)
5076 str = getenv ("SKIP_TEST_CHECKSUM_1");
5077 if (str && strcmp (str, "1") == 0) return 1;
5078 str = getenv ("SKIP_TEST_CHECKSUM");
5079 if (str && strcmp (str, "1") == 0) return 1;
5083 static int test_checksum_1 (void)
5085 if (test_checksum_1_skip ()) {
5086 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_1");
5090 /* InitBasicFS for test_checksum_1: create ext2 on /dev/sda1 */
5092 char device[] = "/dev/sda";
5093 device[5] = devchar;
5096 r = guestfs_blockdev_setrw (g, device);
5103 r = guestfs_umount_all (g);
5110 r = guestfs_lvm_remove_all (g);
5115 char device[] = "/dev/sda";
5116 device[5] = devchar;
5117 char lines_0[] = ",";
5124 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5129 char fstype[] = "ext2";
5130 char device[] = "/dev/sda1";
5131 device[5] = devchar;
5134 r = guestfs_mkfs (g, fstype, device);
5139 char device[] = "/dev/sda1";
5140 device[5] = devchar;
5141 char mountpoint[] = "/";
5144 r = guestfs_mount (g, device, mountpoint);
5148 /* TestLastFail for checksum (1) */
5150 char csumtype[] = "crc";
5151 char path[] = "/new";
5154 r = guestfs_checksum (g, csumtype, path);
5162 static int test_checksum_2_skip (void)
5166 str = getenv ("SKIP_TEST_CHECKSUM_2");
5167 if (str && strcmp (str, "1") == 0) return 1;
5168 str = getenv ("SKIP_TEST_CHECKSUM");
5169 if (str && strcmp (str, "1") == 0) return 1;
5173 static int test_checksum_2 (void)
5175 if (test_checksum_2_skip ()) {
5176 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_2");
5180 /* InitBasicFS for test_checksum_2: create ext2 on /dev/sda1 */
5182 char device[] = "/dev/sda";
5183 device[5] = devchar;
5186 r = guestfs_blockdev_setrw (g, device);
5193 r = guestfs_umount_all (g);
5200 r = guestfs_lvm_remove_all (g);
5205 char device[] = "/dev/sda";
5206 device[5] = devchar;
5207 char lines_0[] = ",";
5214 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5219 char fstype[] = "ext2";
5220 char device[] = "/dev/sda1";
5221 device[5] = devchar;
5224 r = guestfs_mkfs (g, fstype, device);
5229 char device[] = "/dev/sda1";
5230 device[5] = devchar;
5231 char mountpoint[] = "/";
5234 r = guestfs_mount (g, device, mountpoint);
5238 /* TestOutput for checksum (2) */
5239 char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
5241 char path[] = "/new";
5242 char content[] = "test\n";
5245 r = guestfs_write_file (g, path, content, 0);
5250 char csumtype[] = "md5";
5251 char path[] = "/new";
5254 r = guestfs_checksum (g, csumtype, path);
5257 if (strcmp (r, expected) != 0) {
5258 fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
5266 static int test_checksum_3_skip (void)
5270 str = getenv ("SKIP_TEST_CHECKSUM_3");
5271 if (str && strcmp (str, "1") == 0) return 1;
5272 str = getenv ("SKIP_TEST_CHECKSUM");
5273 if (str && strcmp (str, "1") == 0) return 1;
5277 static int test_checksum_3 (void)
5279 if (test_checksum_3_skip ()) {
5280 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_3");
5284 /* InitBasicFS for test_checksum_3: create ext2 on /dev/sda1 */
5286 char device[] = "/dev/sda";
5287 device[5] = devchar;
5290 r = guestfs_blockdev_setrw (g, device);
5297 r = guestfs_umount_all (g);
5304 r = guestfs_lvm_remove_all (g);
5309 char device[] = "/dev/sda";
5310 device[5] = devchar;
5311 char lines_0[] = ",";
5318 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5323 char fstype[] = "ext2";
5324 char device[] = "/dev/sda1";
5325 device[5] = devchar;
5328 r = guestfs_mkfs (g, fstype, device);
5333 char device[] = "/dev/sda1";
5334 device[5] = devchar;
5335 char mountpoint[] = "/";
5338 r = guestfs_mount (g, device, mountpoint);
5342 /* TestOutput for checksum (3) */
5343 char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
5345 char path[] = "/new";
5346 char content[] = "test\n";
5349 r = guestfs_write_file (g, path, content, 0);
5354 char csumtype[] = "sha1";
5355 char path[] = "/new";
5358 r = guestfs_checksum (g, csumtype, path);
5361 if (strcmp (r, expected) != 0) {
5362 fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
5370 static int test_checksum_4_skip (void)
5374 str = getenv ("SKIP_TEST_CHECKSUM_4");
5375 if (str && strcmp (str, "1") == 0) return 1;
5376 str = getenv ("SKIP_TEST_CHECKSUM");
5377 if (str && strcmp (str, "1") == 0) return 1;
5381 static int test_checksum_4 (void)
5383 if (test_checksum_4_skip ()) {
5384 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_4");
5388 /* InitBasicFS for test_checksum_4: create ext2 on /dev/sda1 */
5390 char device[] = "/dev/sda";
5391 device[5] = devchar;
5394 r = guestfs_blockdev_setrw (g, device);
5401 r = guestfs_umount_all (g);
5408 r = guestfs_lvm_remove_all (g);
5413 char device[] = "/dev/sda";
5414 device[5] = devchar;
5415 char lines_0[] = ",";
5422 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5427 char fstype[] = "ext2";
5428 char device[] = "/dev/sda1";
5429 device[5] = devchar;
5432 r = guestfs_mkfs (g, fstype, device);
5437 char device[] = "/dev/sda1";
5438 device[5] = devchar;
5439 char mountpoint[] = "/";
5442 r = guestfs_mount (g, device, mountpoint);
5446 /* TestOutput for checksum (4) */
5447 char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
5449 char path[] = "/new";
5450 char content[] = "test\n";
5453 r = guestfs_write_file (g, path, content, 0);
5458 char csumtype[] = "sha224";
5459 char path[] = "/new";
5462 r = guestfs_checksum (g, csumtype, path);
5465 if (strcmp (r, expected) != 0) {
5466 fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
5474 static int test_checksum_5_skip (void)
5478 str = getenv ("SKIP_TEST_CHECKSUM_5");
5479 if (str && strcmp (str, "1") == 0) return 1;
5480 str = getenv ("SKIP_TEST_CHECKSUM");
5481 if (str && strcmp (str, "1") == 0) return 1;
5485 static int test_checksum_5 (void)
5487 if (test_checksum_5_skip ()) {
5488 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_5");
5492 /* InitBasicFS for test_checksum_5: create ext2 on /dev/sda1 */
5494 char device[] = "/dev/sda";
5495 device[5] = devchar;
5498 r = guestfs_blockdev_setrw (g, device);
5505 r = guestfs_umount_all (g);
5512 r = guestfs_lvm_remove_all (g);
5517 char device[] = "/dev/sda";
5518 device[5] = devchar;
5519 char lines_0[] = ",";
5526 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5531 char fstype[] = "ext2";
5532 char device[] = "/dev/sda1";
5533 device[5] = devchar;
5536 r = guestfs_mkfs (g, fstype, device);
5541 char device[] = "/dev/sda1";
5542 device[5] = devchar;
5543 char mountpoint[] = "/";
5546 r = guestfs_mount (g, device, mountpoint);
5550 /* TestOutput for checksum (5) */
5551 char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
5553 char path[] = "/new";
5554 char content[] = "test\n";
5557 r = guestfs_write_file (g, path, content, 0);
5562 char csumtype[] = "sha256";
5563 char path[] = "/new";
5566 r = guestfs_checksum (g, csumtype, path);
5569 if (strcmp (r, expected) != 0) {
5570 fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
5578 static int test_checksum_6_skip (void)
5582 str = getenv ("SKIP_TEST_CHECKSUM_6");
5583 if (str && strcmp (str, "1") == 0) return 1;
5584 str = getenv ("SKIP_TEST_CHECKSUM");
5585 if (str && strcmp (str, "1") == 0) return 1;
5589 static int test_checksum_6 (void)
5591 if (test_checksum_6_skip ()) {
5592 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_6");
5596 /* InitBasicFS for test_checksum_6: create ext2 on /dev/sda1 */
5598 char device[] = "/dev/sda";
5599 device[5] = devchar;
5602 r = guestfs_blockdev_setrw (g, device);
5609 r = guestfs_umount_all (g);
5616 r = guestfs_lvm_remove_all (g);
5621 char device[] = "/dev/sda";
5622 device[5] = devchar;
5623 char lines_0[] = ",";
5630 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5635 char fstype[] = "ext2";
5636 char device[] = "/dev/sda1";
5637 device[5] = devchar;
5640 r = guestfs_mkfs (g, fstype, device);
5645 char device[] = "/dev/sda1";
5646 device[5] = devchar;
5647 char mountpoint[] = "/";
5650 r = guestfs_mount (g, device, mountpoint);
5654 /* TestOutput for checksum (6) */
5655 char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
5657 char path[] = "/new";
5658 char content[] = "test\n";
5661 r = guestfs_write_file (g, path, content, 0);
5666 char csumtype[] = "sha384";
5667 char path[] = "/new";
5670 r = guestfs_checksum (g, csumtype, path);
5673 if (strcmp (r, expected) != 0) {
5674 fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
5682 static int test_checksum_7_skip (void)
5686 str = getenv ("SKIP_TEST_CHECKSUM_7");
5687 if (str && strcmp (str, "1") == 0) return 1;
5688 str = getenv ("SKIP_TEST_CHECKSUM");
5689 if (str && strcmp (str, "1") == 0) return 1;
5693 static int test_checksum_7 (void)
5695 if (test_checksum_7_skip ()) {
5696 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_7");
5700 /* InitBasicFS for test_checksum_7: create ext2 on /dev/sda1 */
5702 char device[] = "/dev/sda";
5703 device[5] = devchar;
5706 r = guestfs_blockdev_setrw (g, device);
5713 r = guestfs_umount_all (g);
5720 r = guestfs_lvm_remove_all (g);
5725 char device[] = "/dev/sda";
5726 device[5] = devchar;
5727 char lines_0[] = ",";
5734 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5739 char fstype[] = "ext2";
5740 char device[] = "/dev/sda1";
5741 device[5] = devchar;
5744 r = guestfs_mkfs (g, fstype, device);
5749 char device[] = "/dev/sda1";
5750 device[5] = devchar;
5751 char mountpoint[] = "/";
5754 r = guestfs_mount (g, device, mountpoint);
5758 /* TestOutput for checksum (7) */
5759 char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
5761 char path[] = "/new";
5762 char content[] = "test\n";
5765 r = guestfs_write_file (g, path, content, 0);
5770 char csumtype[] = "sha512";
5771 char path[] = "/new";
5774 r = guestfs_checksum (g, csumtype, path);
5777 if (strcmp (r, expected) != 0) {
5778 fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
5786 static int test_checksum_8_skip (void)
5790 str = getenv ("SKIP_TEST_CHECKSUM_8");
5791 if (str && strcmp (str, "1") == 0) return 1;
5792 str = getenv ("SKIP_TEST_CHECKSUM");
5793 if (str && strcmp (str, "1") == 0) return 1;
5797 static int test_checksum_8 (void)
5799 if (test_checksum_8_skip ()) {
5800 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_8");
5804 /* InitBasicFS for test_checksum_8: create ext2 on /dev/sda1 */
5806 char device[] = "/dev/sda";
5807 device[5] = devchar;
5810 r = guestfs_blockdev_setrw (g, device);
5817 r = guestfs_umount_all (g);
5824 r = guestfs_lvm_remove_all (g);
5829 char device[] = "/dev/sda";
5830 device[5] = devchar;
5831 char lines_0[] = ",";
5838 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5843 char fstype[] = "ext2";
5844 char device[] = "/dev/sda1";
5845 device[5] = devchar;
5848 r = guestfs_mkfs (g, fstype, device);
5853 char device[] = "/dev/sda1";
5854 device[5] = devchar;
5855 char mountpoint[] = "/";
5858 r = guestfs_mount (g, device, mountpoint);
5862 /* TestOutput for checksum (8) */
5863 char expected[] = "46d6ca27ee07cdc6fa99c2e138cc522c";
5865 char device[] = "/dev/sdd";
5866 device[5] = devchar;
5867 char mountpoint[] = "/";
5870 r = guestfs_mount (g, device, mountpoint);
5875 char csumtype[] = "md5";
5876 char path[] = "/known-3";
5879 r = guestfs_checksum (g, csumtype, path);
5882 if (strcmp (r, expected) != 0) {
5883 fprintf (stderr, "test_checksum_8: expected \"%s\" but got \"%s\"\n", expected, r);
5891 static int test_download_0_skip (void)
5895 str = getenv ("SKIP_TEST_DOWNLOAD_0");
5896 if (str && strcmp (str, "1") == 0) return 1;
5897 str = getenv ("SKIP_TEST_DOWNLOAD");
5898 if (str && strcmp (str, "1") == 0) return 1;
5902 static int test_download_0 (void)
5904 if (test_download_0_skip ()) {
5905 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_download_0");
5909 /* InitBasicFS for test_download_0: create ext2 on /dev/sda1 */
5911 char device[] = "/dev/sda";
5912 device[5] = devchar;
5915 r = guestfs_blockdev_setrw (g, device);
5922 r = guestfs_umount_all (g);
5929 r = guestfs_lvm_remove_all (g);
5934 char device[] = "/dev/sda";
5935 device[5] = devchar;
5936 char lines_0[] = ",";
5943 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5948 char fstype[] = "ext2";
5949 char device[] = "/dev/sda1";
5950 device[5] = devchar;
5953 r = guestfs_mkfs (g, fstype, device);
5958 char device[] = "/dev/sda1";
5959 device[5] = devchar;
5960 char mountpoint[] = "/";
5963 r = guestfs_mount (g, device, mountpoint);
5967 /* TestOutput for download (0) */
5968 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
5970 char remotefilename[] = "/COPYING.LIB";
5973 r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
5978 char remotefilename[] = "/COPYING.LIB";
5981 r = guestfs_download (g, remotefilename, "testdownload.tmp");
5986 char remotefilename[] = "/upload";
5989 r = guestfs_upload (g, "testdownload.tmp", remotefilename);
5994 char csumtype[] = "md5";
5995 char path[] = "/upload";
5998 r = guestfs_checksum (g, csumtype, path);
6001 if (strcmp (r, expected) != 0) {
6002 fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
6010 static int test_upload_0_skip (void)
6014 str = getenv ("SKIP_TEST_UPLOAD_0");
6015 if (str && strcmp (str, "1") == 0) return 1;
6016 str = getenv ("SKIP_TEST_UPLOAD");
6017 if (str && strcmp (str, "1") == 0) return 1;
6021 static int test_upload_0 (void)
6023 if (test_upload_0_skip ()) {
6024 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_upload_0");
6028 /* InitBasicFS for test_upload_0: create ext2 on /dev/sda1 */
6030 char device[] = "/dev/sda";
6031 device[5] = devchar;
6034 r = guestfs_blockdev_setrw (g, device);
6041 r = guestfs_umount_all (g);
6048 r = guestfs_lvm_remove_all (g);
6053 char device[] = "/dev/sda";
6054 device[5] = devchar;
6055 char lines_0[] = ",";
6062 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6067 char fstype[] = "ext2";
6068 char device[] = "/dev/sda1";
6069 device[5] = devchar;
6072 r = guestfs_mkfs (g, fstype, device);
6077 char device[] = "/dev/sda1";
6078 device[5] = devchar;
6079 char mountpoint[] = "/";
6082 r = guestfs_mount (g, device, mountpoint);
6086 /* TestOutput for upload (0) */
6087 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
6089 char remotefilename[] = "/COPYING.LIB";
6092 r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
6097 char csumtype[] = "md5";
6098 char path[] = "/COPYING.LIB";
6101 r = guestfs_checksum (g, csumtype, path);
6104 if (strcmp (r, expected) != 0) {
6105 fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
6113 static int test_blockdev_rereadpt_0_skip (void)
6117 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT_0");
6118 if (str && strcmp (str, "1") == 0) return 1;
6119 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT");
6120 if (str && strcmp (str, "1") == 0) return 1;
6124 static int test_blockdev_rereadpt_0 (void)
6126 if (test_blockdev_rereadpt_0_skip ()) {
6127 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_rereadpt_0");
6131 /* InitNone|InitEmpty for test_blockdev_rereadpt_0 */
6133 char device[] = "/dev/sda";
6134 device[5] = devchar;
6137 r = guestfs_blockdev_setrw (g, device);
6144 r = guestfs_umount_all (g);
6151 r = guestfs_lvm_remove_all (g);
6155 /* TestRun for blockdev_rereadpt (0) */
6157 char device[] = "/dev/sda";
6158 device[5] = devchar;
6161 r = guestfs_blockdev_rereadpt (g, device);
6168 static int test_blockdev_flushbufs_0_skip (void)
6172 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS_0");
6173 if (str && strcmp (str, "1") == 0) return 1;
6174 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS");
6175 if (str && strcmp (str, "1") == 0) return 1;
6179 static int test_blockdev_flushbufs_0 (void)
6181 if (test_blockdev_flushbufs_0_skip ()) {
6182 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_flushbufs_0");
6186 /* InitNone|InitEmpty for test_blockdev_flushbufs_0 */
6188 char device[] = "/dev/sda";
6189 device[5] = devchar;
6192 r = guestfs_blockdev_setrw (g, device);
6199 r = guestfs_umount_all (g);
6206 r = guestfs_lvm_remove_all (g);
6210 /* TestRun for blockdev_flushbufs (0) */
6212 char device[] = "/dev/sda";
6213 device[5] = devchar;
6216 r = guestfs_blockdev_flushbufs (g, device);
6223 static int test_blockdev_getsize64_0_skip (void)
6227 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64_0");
6228 if (str && strcmp (str, "1") == 0) return 1;
6229 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64");
6230 if (str && strcmp (str, "1") == 0) return 1;
6234 static int test_blockdev_getsize64_0 (void)
6236 if (test_blockdev_getsize64_0_skip ()) {
6237 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsize64_0");
6241 /* InitNone|InitEmpty for test_blockdev_getsize64_0 */
6243 char device[] = "/dev/sda";
6244 device[5] = devchar;
6247 r = guestfs_blockdev_setrw (g, device);
6254 r = guestfs_umount_all (g);
6261 r = guestfs_lvm_remove_all (g);
6265 /* TestOutputInt for blockdev_getsize64 (0) */
6267 char device[] = "/dev/sda";
6268 device[5] = devchar;
6271 r = guestfs_blockdev_getsize64 (g, device);
6274 if (r != 524288000) {
6275 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
6282 static int test_blockdev_getsz_0_skip (void)
6286 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ_0");
6287 if (str && strcmp (str, "1") == 0) return 1;
6288 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ");
6289 if (str && strcmp (str, "1") == 0) return 1;
6293 static int test_blockdev_getsz_0 (void)
6295 if (test_blockdev_getsz_0_skip ()) {
6296 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsz_0");
6300 /* InitNone|InitEmpty for test_blockdev_getsz_0 */
6302 char device[] = "/dev/sda";
6303 device[5] = devchar;
6306 r = guestfs_blockdev_setrw (g, device);
6313 r = guestfs_umount_all (g);
6320 r = guestfs_lvm_remove_all (g);
6324 /* TestOutputInt for blockdev_getsz (0) */
6326 char device[] = "/dev/sda";
6327 device[5] = devchar;
6330 r = guestfs_blockdev_getsz (g, device);
6334 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
6341 static int test_blockdev_getbsz_0_skip (void)
6345 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ_0");
6346 if (str && strcmp (str, "1") == 0) return 1;
6347 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ");
6348 if (str && strcmp (str, "1") == 0) return 1;
6352 static int test_blockdev_getbsz_0 (void)
6354 if (test_blockdev_getbsz_0_skip ()) {
6355 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getbsz_0");
6359 /* InitNone|InitEmpty for test_blockdev_getbsz_0 */
6361 char device[] = "/dev/sda";
6362 device[5] = devchar;
6365 r = guestfs_blockdev_setrw (g, device);
6372 r = guestfs_umount_all (g);
6379 r = guestfs_lvm_remove_all (g);
6383 /* TestOutputInt for blockdev_getbsz (0) */
6385 char device[] = "/dev/sda";
6386 device[5] = devchar;
6389 r = guestfs_blockdev_getbsz (g, device);
6393 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
6400 static int test_blockdev_getss_0_skip (void)
6404 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS_0");
6405 if (str && strcmp (str, "1") == 0) return 1;
6406 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS");
6407 if (str && strcmp (str, "1") == 0) return 1;
6411 static int test_blockdev_getss_0 (void)
6413 if (test_blockdev_getss_0_skip ()) {
6414 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getss_0");
6418 /* InitNone|InitEmpty for test_blockdev_getss_0 */
6420 char device[] = "/dev/sda";
6421 device[5] = devchar;
6424 r = guestfs_blockdev_setrw (g, device);
6431 r = guestfs_umount_all (g);
6438 r = guestfs_lvm_remove_all (g);
6442 /* TestOutputInt for blockdev_getss (0) */
6444 char device[] = "/dev/sda";
6445 device[5] = devchar;
6448 r = guestfs_blockdev_getss (g, device);
6452 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
6459 static int test_blockdev_getro_0_skip (void)
6463 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO_0");
6464 if (str && strcmp (str, "1") == 0) return 1;
6465 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO");
6466 if (str && strcmp (str, "1") == 0) return 1;
6470 static int test_blockdev_getro_0 (void)
6472 if (test_blockdev_getro_0_skip ()) {
6473 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getro_0");
6477 /* InitNone|InitEmpty for test_blockdev_getro_0 */
6479 char device[] = "/dev/sda";
6480 device[5] = devchar;
6483 r = guestfs_blockdev_setrw (g, device);
6490 r = guestfs_umount_all (g);
6497 r = guestfs_lvm_remove_all (g);
6501 /* TestOutputTrue for blockdev_getro (0) */
6503 char device[] = "/dev/sda";
6504 device[5] = devchar;
6507 r = guestfs_blockdev_setro (g, device);
6512 char device[] = "/dev/sda";
6513 device[5] = devchar;
6516 r = guestfs_blockdev_getro (g, device);
6520 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
6527 static int test_blockdev_setrw_0_skip (void)
6531 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW_0");
6532 if (str && strcmp (str, "1") == 0) return 1;
6533 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW");
6534 if (str && strcmp (str, "1") == 0) return 1;
6538 static int test_blockdev_setrw_0 (void)
6540 if (test_blockdev_setrw_0_skip ()) {
6541 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setrw_0");
6545 /* InitNone|InitEmpty for test_blockdev_setrw_0 */
6547 char device[] = "/dev/sda";
6548 device[5] = devchar;
6551 r = guestfs_blockdev_setrw (g, device);
6558 r = guestfs_umount_all (g);
6565 r = guestfs_lvm_remove_all (g);
6569 /* TestOutputFalse for blockdev_setrw (0) */
6571 char device[] = "/dev/sda";
6572 device[5] = devchar;
6575 r = guestfs_blockdev_setrw (g, device);
6580 char device[] = "/dev/sda";
6581 device[5] = devchar;
6584 r = guestfs_blockdev_getro (g, device);
6588 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
6595 static int test_blockdev_setro_0_skip (void)
6599 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO_0");
6600 if (str && strcmp (str, "1") == 0) return 1;
6601 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO");
6602 if (str && strcmp (str, "1") == 0) return 1;
6606 static int test_blockdev_setro_0 (void)
6608 if (test_blockdev_setro_0_skip ()) {
6609 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setro_0");
6613 /* InitNone|InitEmpty for test_blockdev_setro_0 */
6615 char device[] = "/dev/sda";
6616 device[5] = devchar;
6619 r = guestfs_blockdev_setrw (g, device);
6626 r = guestfs_umount_all (g);
6633 r = guestfs_lvm_remove_all (g);
6637 /* TestOutputTrue for blockdev_setro (0) */
6639 char device[] = "/dev/sda";
6640 device[5] = devchar;
6643 r = guestfs_blockdev_setro (g, device);
6648 char device[] = "/dev/sda";
6649 device[5] = devchar;
6652 r = guestfs_blockdev_getro (g, device);
6656 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
6663 static int test_statvfs_0_skip (void)
6667 str = getenv ("SKIP_TEST_STATVFS_0");
6668 if (str && strcmp (str, "1") == 0) return 1;
6669 str = getenv ("SKIP_TEST_STATVFS");
6670 if (str && strcmp (str, "1") == 0) return 1;
6674 static int test_statvfs_0 (void)
6676 if (test_statvfs_0_skip ()) {
6677 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_statvfs_0");
6681 /* InitBasicFS for test_statvfs_0: create ext2 on /dev/sda1 */
6683 char device[] = "/dev/sda";
6684 device[5] = devchar;
6687 r = guestfs_blockdev_setrw (g, device);
6694 r = guestfs_umount_all (g);
6701 r = guestfs_lvm_remove_all (g);
6706 char device[] = "/dev/sda";
6707 device[5] = devchar;
6708 char lines_0[] = ",";
6715 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6720 char fstype[] = "ext2";
6721 char device[] = "/dev/sda1";
6722 device[5] = devchar;
6725 r = guestfs_mkfs (g, fstype, device);
6730 char device[] = "/dev/sda1";
6731 device[5] = devchar;
6732 char mountpoint[] = "/";
6735 r = guestfs_mount (g, device, mountpoint);
6739 /* TestOutputStruct for statvfs (0) */
6742 struct guestfs_statvfs *r;
6744 r = guestfs_statvfs (g, path);
6747 if (r->bfree != 487702) {
6748 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
6752 if (r->blocks != 490020) {
6753 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
6757 if (r->bsize != 1024) {
6758 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
6767 static int test_lstat_0_skip (void)
6771 str = getenv ("SKIP_TEST_LSTAT_0");
6772 if (str && strcmp (str, "1") == 0) return 1;
6773 str = getenv ("SKIP_TEST_LSTAT");
6774 if (str && strcmp (str, "1") == 0) return 1;
6778 static int test_lstat_0 (void)
6780 if (test_lstat_0_skip ()) {
6781 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lstat_0");
6785 /* InitBasicFS for test_lstat_0: create ext2 on /dev/sda1 */
6787 char device[] = "/dev/sda";
6788 device[5] = devchar;
6791 r = guestfs_blockdev_setrw (g, device);
6798 r = guestfs_umount_all (g);
6805 r = guestfs_lvm_remove_all (g);
6810 char device[] = "/dev/sda";
6811 device[5] = devchar;
6812 char lines_0[] = ",";
6819 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6824 char fstype[] = "ext2";
6825 char device[] = "/dev/sda1";
6826 device[5] = devchar;
6829 r = guestfs_mkfs (g, fstype, device);
6834 char device[] = "/dev/sda1";
6835 device[5] = devchar;
6836 char mountpoint[] = "/";
6839 r = guestfs_mount (g, device, mountpoint);
6843 /* TestOutputStruct for lstat (0) */
6845 char path[] = "/new";
6848 r = guestfs_touch (g, path);
6853 char path[] = "/new";
6854 struct guestfs_stat *r;
6856 r = guestfs_lstat (g, path);
6860 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
6869 static int test_stat_0_skip (void)
6873 str = getenv ("SKIP_TEST_STAT_0");
6874 if (str && strcmp (str, "1") == 0) return 1;
6875 str = getenv ("SKIP_TEST_STAT");
6876 if (str && strcmp (str, "1") == 0) return 1;
6880 static int test_stat_0 (void)
6882 if (test_stat_0_skip ()) {
6883 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_stat_0");
6887 /* InitBasicFS for test_stat_0: create ext2 on /dev/sda1 */
6889 char device[] = "/dev/sda";
6890 device[5] = devchar;
6893 r = guestfs_blockdev_setrw (g, device);
6900 r = guestfs_umount_all (g);
6907 r = guestfs_lvm_remove_all (g);
6912 char device[] = "/dev/sda";
6913 device[5] = devchar;
6914 char lines_0[] = ",";
6921 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6926 char fstype[] = "ext2";
6927 char device[] = "/dev/sda1";
6928 device[5] = devchar;
6931 r = guestfs_mkfs (g, fstype, device);
6936 char device[] = "/dev/sda1";
6937 device[5] = devchar;
6938 char mountpoint[] = "/";
6941 r = guestfs_mount (g, device, mountpoint);
6945 /* TestOutputStruct for stat (0) */
6947 char path[] = "/new";
6950 r = guestfs_touch (g, path);
6955 char path[] = "/new";
6956 struct guestfs_stat *r;
6958 r = guestfs_stat (g, path);
6962 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
6971 static int test_command_lines_0_skip (void)
6975 str = getenv ("SKIP_TEST_COMMAND_LINES_0");
6976 if (str && strcmp (str, "1") == 0) return 1;
6977 str = getenv ("SKIP_TEST_COMMAND_LINES");
6978 if (str && strcmp (str, "1") == 0) return 1;
6982 static int test_command_lines_0 (void)
6984 if (test_command_lines_0_skip ()) {
6985 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_0");
6989 /* InitBasicFS for test_command_lines_0: create ext2 on /dev/sda1 */
6991 char device[] = "/dev/sda";
6992 device[5] = devchar;
6995 r = guestfs_blockdev_setrw (g, device);
7002 r = guestfs_umount_all (g);
7009 r = guestfs_lvm_remove_all (g);
7014 char device[] = "/dev/sda";
7015 device[5] = devchar;
7016 char lines_0[] = ",";
7023 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7028 char fstype[] = "ext2";
7029 char device[] = "/dev/sda1";
7030 device[5] = devchar;
7033 r = guestfs_mkfs (g, fstype, device);
7038 char device[] = "/dev/sda1";
7039 device[5] = devchar;
7040 char mountpoint[] = "/";
7043 r = guestfs_mount (g, device, mountpoint);
7047 /* TestOutputList for command_lines (0) */
7049 char remotefilename[] = "/test-command";
7052 r = guestfs_upload (g, "test-command", remotefilename);
7057 char path[] = "/test-command";
7060 r = guestfs_chmod (g, 493, path);
7065 char arguments_0[] = "/test-command";
7066 char arguments_1[] = "1";
7067 char *arguments[] = {
7075 r = guestfs_command_lines (g, arguments);
7079 fprintf (stderr, "test_command_lines_0: short list returned from command\n");
7084 char expected[] = "Result1";
7085 if (strcmp (r[0], expected) != 0) {
7086 fprintf (stderr, "test_command_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7091 fprintf (stderr, "test_command_lines_0: extra elements returned from command\n");
7095 for (i = 0; r[i] != NULL; ++i)
7102 static int test_command_lines_1_skip (void)
7106 str = getenv ("SKIP_TEST_COMMAND_LINES_1");
7107 if (str && strcmp (str, "1") == 0) return 1;
7108 str = getenv ("SKIP_TEST_COMMAND_LINES");
7109 if (str && strcmp (str, "1") == 0) return 1;
7113 static int test_command_lines_1 (void)
7115 if (test_command_lines_1_skip ()) {
7116 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_1");
7120 /* InitBasicFS for test_command_lines_1: create ext2 on /dev/sda1 */
7122 char device[] = "/dev/sda";
7123 device[5] = devchar;
7126 r = guestfs_blockdev_setrw (g, device);
7133 r = guestfs_umount_all (g);
7140 r = guestfs_lvm_remove_all (g);
7145 char device[] = "/dev/sda";
7146 device[5] = devchar;
7147 char lines_0[] = ",";
7154 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7159 char fstype[] = "ext2";
7160 char device[] = "/dev/sda1";
7161 device[5] = devchar;
7164 r = guestfs_mkfs (g, fstype, device);
7169 char device[] = "/dev/sda1";
7170 device[5] = devchar;
7171 char mountpoint[] = "/";
7174 r = guestfs_mount (g, device, mountpoint);
7178 /* TestOutputList for command_lines (1) */
7180 char remotefilename[] = "/test-command";
7183 r = guestfs_upload (g, "test-command", remotefilename);
7188 char path[] = "/test-command";
7191 r = guestfs_chmod (g, 493, path);
7196 char arguments_0[] = "/test-command";
7197 char arguments_1[] = "2";
7198 char *arguments[] = {
7206 r = guestfs_command_lines (g, arguments);
7210 fprintf (stderr, "test_command_lines_1: short list returned from command\n");
7215 char expected[] = "Result2";
7216 if (strcmp (r[0], expected) != 0) {
7217 fprintf (stderr, "test_command_lines_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7222 fprintf (stderr, "test_command_lines_1: extra elements returned from command\n");
7226 for (i = 0; r[i] != NULL; ++i)
7233 static int test_command_lines_2_skip (void)
7237 str = getenv ("SKIP_TEST_COMMAND_LINES_2");
7238 if (str && strcmp (str, "1") == 0) return 1;
7239 str = getenv ("SKIP_TEST_COMMAND_LINES");
7240 if (str && strcmp (str, "1") == 0) return 1;
7244 static int test_command_lines_2 (void)
7246 if (test_command_lines_2_skip ()) {
7247 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_2");
7251 /* InitBasicFS for test_command_lines_2: create ext2 on /dev/sda1 */
7253 char device[] = "/dev/sda";
7254 device[5] = devchar;
7257 r = guestfs_blockdev_setrw (g, device);
7264 r = guestfs_umount_all (g);
7271 r = guestfs_lvm_remove_all (g);
7276 char device[] = "/dev/sda";
7277 device[5] = devchar;
7278 char lines_0[] = ",";
7285 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7290 char fstype[] = "ext2";
7291 char device[] = "/dev/sda1";
7292 device[5] = devchar;
7295 r = guestfs_mkfs (g, fstype, device);
7300 char device[] = "/dev/sda1";
7301 device[5] = devchar;
7302 char mountpoint[] = "/";
7305 r = guestfs_mount (g, device, mountpoint);
7309 /* TestOutputList for command_lines (2) */
7311 char remotefilename[] = "/test-command";
7314 r = guestfs_upload (g, "test-command", remotefilename);
7319 char path[] = "/test-command";
7322 r = guestfs_chmod (g, 493, path);
7327 char arguments_0[] = "/test-command";
7328 char arguments_1[] = "3";
7329 char *arguments[] = {
7337 r = guestfs_command_lines (g, arguments);
7341 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7346 char expected[] = "";
7347 if (strcmp (r[0], expected) != 0) {
7348 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7353 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7358 char expected[] = "Result3";
7359 if (strcmp (r[1], expected) != 0) {
7360 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7365 fprintf (stderr, "test_command_lines_2: extra elements returned from command\n");
7369 for (i = 0; r[i] != NULL; ++i)
7376 static int test_command_lines_3_skip (void)
7380 str = getenv ("SKIP_TEST_COMMAND_LINES_3");
7381 if (str && strcmp (str, "1") == 0) return 1;
7382 str = getenv ("SKIP_TEST_COMMAND_LINES");
7383 if (str && strcmp (str, "1") == 0) return 1;
7387 static int test_command_lines_3 (void)
7389 if (test_command_lines_3_skip ()) {
7390 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_3");
7394 /* InitBasicFS for test_command_lines_3: create ext2 on /dev/sda1 */
7396 char device[] = "/dev/sda";
7397 device[5] = devchar;
7400 r = guestfs_blockdev_setrw (g, device);
7407 r = guestfs_umount_all (g);
7414 r = guestfs_lvm_remove_all (g);
7419 char device[] = "/dev/sda";
7420 device[5] = devchar;
7421 char lines_0[] = ",";
7428 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7433 char fstype[] = "ext2";
7434 char device[] = "/dev/sda1";
7435 device[5] = devchar;
7438 r = guestfs_mkfs (g, fstype, device);
7443 char device[] = "/dev/sda1";
7444 device[5] = devchar;
7445 char mountpoint[] = "/";
7448 r = guestfs_mount (g, device, mountpoint);
7452 /* TestOutputList for command_lines (3) */
7454 char remotefilename[] = "/test-command";
7457 r = guestfs_upload (g, "test-command", remotefilename);
7462 char path[] = "/test-command";
7465 r = guestfs_chmod (g, 493, path);
7470 char arguments_0[] = "/test-command";
7471 char arguments_1[] = "4";
7472 char *arguments[] = {
7480 r = guestfs_command_lines (g, arguments);
7484 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
7489 char expected[] = "";
7490 if (strcmp (r[0], expected) != 0) {
7491 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7496 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
7501 char expected[] = "Result4";
7502 if (strcmp (r[1], expected) != 0) {
7503 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7508 fprintf (stderr, "test_command_lines_3: extra elements returned from command\n");
7512 for (i = 0; r[i] != NULL; ++i)
7519 static int test_command_lines_4_skip (void)
7523 str = getenv ("SKIP_TEST_COMMAND_LINES_4");
7524 if (str && strcmp (str, "1") == 0) return 1;
7525 str = getenv ("SKIP_TEST_COMMAND_LINES");
7526 if (str && strcmp (str, "1") == 0) return 1;
7530 static int test_command_lines_4 (void)
7532 if (test_command_lines_4_skip ()) {
7533 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_4");
7537 /* InitBasicFS for test_command_lines_4: create ext2 on /dev/sda1 */
7539 char device[] = "/dev/sda";
7540 device[5] = devchar;
7543 r = guestfs_blockdev_setrw (g, device);
7550 r = guestfs_umount_all (g);
7557 r = guestfs_lvm_remove_all (g);
7562 char device[] = "/dev/sda";
7563 device[5] = devchar;
7564 char lines_0[] = ",";
7571 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7576 char fstype[] = "ext2";
7577 char device[] = "/dev/sda1";
7578 device[5] = devchar;
7581 r = guestfs_mkfs (g, fstype, device);
7586 char device[] = "/dev/sda1";
7587 device[5] = devchar;
7588 char mountpoint[] = "/";
7591 r = guestfs_mount (g, device, mountpoint);
7595 /* TestOutputList for command_lines (4) */
7597 char remotefilename[] = "/test-command";
7600 r = guestfs_upload (g, "test-command", remotefilename);
7605 char path[] = "/test-command";
7608 r = guestfs_chmod (g, 493, path);
7613 char arguments_0[] = "/test-command";
7614 char arguments_1[] = "5";
7615 char *arguments[] = {
7623 r = guestfs_command_lines (g, arguments);
7627 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7632 char expected[] = "";
7633 if (strcmp (r[0], expected) != 0) {
7634 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7639 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7644 char expected[] = "Result5";
7645 if (strcmp (r[1], expected) != 0) {
7646 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7651 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7656 char expected[] = "";
7657 if (strcmp (r[2], expected) != 0) {
7658 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[2]);
7663 fprintf (stderr, "test_command_lines_4: extra elements returned from command\n");
7667 for (i = 0; r[i] != NULL; ++i)
7674 static int test_command_lines_5_skip (void)
7678 str = getenv ("SKIP_TEST_COMMAND_LINES_5");
7679 if (str && strcmp (str, "1") == 0) return 1;
7680 str = getenv ("SKIP_TEST_COMMAND_LINES");
7681 if (str && strcmp (str, "1") == 0) return 1;
7685 static int test_command_lines_5 (void)
7687 if (test_command_lines_5_skip ()) {
7688 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_5");
7692 /* InitBasicFS for test_command_lines_5: create ext2 on /dev/sda1 */
7694 char device[] = "/dev/sda";
7695 device[5] = devchar;
7698 r = guestfs_blockdev_setrw (g, device);
7705 r = guestfs_umount_all (g);
7712 r = guestfs_lvm_remove_all (g);
7717 char device[] = "/dev/sda";
7718 device[5] = devchar;
7719 char lines_0[] = ",";
7726 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7731 char fstype[] = "ext2";
7732 char device[] = "/dev/sda1";
7733 device[5] = devchar;
7736 r = guestfs_mkfs (g, fstype, device);
7741 char device[] = "/dev/sda1";
7742 device[5] = devchar;
7743 char mountpoint[] = "/";
7746 r = guestfs_mount (g, device, mountpoint);
7750 /* TestOutputList for command_lines (5) */
7752 char remotefilename[] = "/test-command";
7755 r = guestfs_upload (g, "test-command", remotefilename);
7760 char path[] = "/test-command";
7763 r = guestfs_chmod (g, 493, path);
7768 char arguments_0[] = "/test-command";
7769 char arguments_1[] = "6";
7770 char *arguments[] = {
7778 r = guestfs_command_lines (g, arguments);
7782 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7787 char expected[] = "";
7788 if (strcmp (r[0], expected) != 0) {
7789 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7794 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7799 char expected[] = "";
7800 if (strcmp (r[1], expected) != 0) {
7801 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7806 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7811 char expected[] = "Result6";
7812 if (strcmp (r[2], expected) != 0) {
7813 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[2]);
7818 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7823 char expected[] = "";
7824 if (strcmp (r[3], expected) != 0) {
7825 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[3]);
7830 fprintf (stderr, "test_command_lines_5: extra elements returned from command\n");
7834 for (i = 0; r[i] != NULL; ++i)
7841 static int test_command_lines_6_skip (void)
7845 str = getenv ("SKIP_TEST_COMMAND_LINES_6");
7846 if (str && strcmp (str, "1") == 0) return 1;
7847 str = getenv ("SKIP_TEST_COMMAND_LINES");
7848 if (str && strcmp (str, "1") == 0) return 1;
7852 static int test_command_lines_6 (void)
7854 if (test_command_lines_6_skip ()) {
7855 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_6");
7859 /* InitBasicFS for test_command_lines_6: create ext2 on /dev/sda1 */
7861 char device[] = "/dev/sda";
7862 device[5] = devchar;
7865 r = guestfs_blockdev_setrw (g, device);
7872 r = guestfs_umount_all (g);
7879 r = guestfs_lvm_remove_all (g);
7884 char device[] = "/dev/sda";
7885 device[5] = devchar;
7886 char lines_0[] = ",";
7893 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7898 char fstype[] = "ext2";
7899 char device[] = "/dev/sda1";
7900 device[5] = devchar;
7903 r = guestfs_mkfs (g, fstype, device);
7908 char device[] = "/dev/sda1";
7909 device[5] = devchar;
7910 char mountpoint[] = "/";
7913 r = guestfs_mount (g, device, mountpoint);
7917 /* TestOutputList for command_lines (6) */
7919 char remotefilename[] = "/test-command";
7922 r = guestfs_upload (g, "test-command", remotefilename);
7927 char path[] = "/test-command";
7930 r = guestfs_chmod (g, 493, path);
7935 char arguments_0[] = "/test-command";
7936 char arguments_1[] = "7";
7937 char *arguments[] = {
7945 r = guestfs_command_lines (g, arguments);
7949 fprintf (stderr, "test_command_lines_6: extra elements returned from command\n");
7953 for (i = 0; r[i] != NULL; ++i)
7960 static int test_command_lines_7_skip (void)
7964 str = getenv ("SKIP_TEST_COMMAND_LINES_7");
7965 if (str && strcmp (str, "1") == 0) return 1;
7966 str = getenv ("SKIP_TEST_COMMAND_LINES");
7967 if (str && strcmp (str, "1") == 0) return 1;
7971 static int test_command_lines_7 (void)
7973 if (test_command_lines_7_skip ()) {
7974 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_7");
7978 /* InitBasicFS for test_command_lines_7: create ext2 on /dev/sda1 */
7980 char device[] = "/dev/sda";
7981 device[5] = devchar;
7984 r = guestfs_blockdev_setrw (g, device);
7991 r = guestfs_umount_all (g);
7998 r = guestfs_lvm_remove_all (g);
8003 char device[] = "/dev/sda";
8004 device[5] = devchar;
8005 char lines_0[] = ",";
8012 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8017 char fstype[] = "ext2";
8018 char device[] = "/dev/sda1";
8019 device[5] = devchar;
8022 r = guestfs_mkfs (g, fstype, device);
8027 char device[] = "/dev/sda1";
8028 device[5] = devchar;
8029 char mountpoint[] = "/";
8032 r = guestfs_mount (g, device, mountpoint);
8036 /* TestOutputList for command_lines (7) */
8038 char remotefilename[] = "/test-command";
8041 r = guestfs_upload (g, "test-command", remotefilename);
8046 char path[] = "/test-command";
8049 r = guestfs_chmod (g, 493, path);
8054 char arguments_0[] = "/test-command";
8055 char arguments_1[] = "8";
8056 char *arguments[] = {
8064 r = guestfs_command_lines (g, arguments);
8068 fprintf (stderr, "test_command_lines_7: short list returned from command\n");
8073 char expected[] = "";
8074 if (strcmp (r[0], expected) != 0) {
8075 fprintf (stderr, "test_command_lines_7: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8080 fprintf (stderr, "test_command_lines_7: extra elements returned from command\n");
8084 for (i = 0; r[i] != NULL; ++i)
8091 static int test_command_lines_8_skip (void)
8095 str = getenv ("SKIP_TEST_COMMAND_LINES_8");
8096 if (str && strcmp (str, "1") == 0) return 1;
8097 str = getenv ("SKIP_TEST_COMMAND_LINES");
8098 if (str && strcmp (str, "1") == 0) return 1;
8102 static int test_command_lines_8 (void)
8104 if (test_command_lines_8_skip ()) {
8105 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_8");
8109 /* InitBasicFS for test_command_lines_8: create ext2 on /dev/sda1 */
8111 char device[] = "/dev/sda";
8112 device[5] = devchar;
8115 r = guestfs_blockdev_setrw (g, device);
8122 r = guestfs_umount_all (g);
8129 r = guestfs_lvm_remove_all (g);
8134 char device[] = "/dev/sda";
8135 device[5] = devchar;
8136 char lines_0[] = ",";
8143 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8148 char fstype[] = "ext2";
8149 char device[] = "/dev/sda1";
8150 device[5] = devchar;
8153 r = guestfs_mkfs (g, fstype, device);
8158 char device[] = "/dev/sda1";
8159 device[5] = devchar;
8160 char mountpoint[] = "/";
8163 r = guestfs_mount (g, device, mountpoint);
8167 /* TestOutputList for command_lines (8) */
8169 char remotefilename[] = "/test-command";
8172 r = guestfs_upload (g, "test-command", remotefilename);
8177 char path[] = "/test-command";
8180 r = guestfs_chmod (g, 493, path);
8185 char arguments_0[] = "/test-command";
8186 char arguments_1[] = "9";
8187 char *arguments[] = {
8195 r = guestfs_command_lines (g, arguments);
8199 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8204 char expected[] = "";
8205 if (strcmp (r[0], expected) != 0) {
8206 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8211 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8216 char expected[] = "";
8217 if (strcmp (r[1], expected) != 0) {
8218 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8223 fprintf (stderr, "test_command_lines_8: extra elements returned from command\n");
8227 for (i = 0; r[i] != NULL; ++i)
8234 static int test_command_lines_9_skip (void)
8238 str = getenv ("SKIP_TEST_COMMAND_LINES_9");
8239 if (str && strcmp (str, "1") == 0) return 1;
8240 str = getenv ("SKIP_TEST_COMMAND_LINES");
8241 if (str && strcmp (str, "1") == 0) return 1;
8245 static int test_command_lines_9 (void)
8247 if (test_command_lines_9_skip ()) {
8248 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_9");
8252 /* InitBasicFS for test_command_lines_9: create ext2 on /dev/sda1 */
8254 char device[] = "/dev/sda";
8255 device[5] = devchar;
8258 r = guestfs_blockdev_setrw (g, device);
8265 r = guestfs_umount_all (g);
8272 r = guestfs_lvm_remove_all (g);
8277 char device[] = "/dev/sda";
8278 device[5] = devchar;
8279 char lines_0[] = ",";
8286 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8291 char fstype[] = "ext2";
8292 char device[] = "/dev/sda1";
8293 device[5] = devchar;
8296 r = guestfs_mkfs (g, fstype, device);
8301 char device[] = "/dev/sda1";
8302 device[5] = devchar;
8303 char mountpoint[] = "/";
8306 r = guestfs_mount (g, device, mountpoint);
8310 /* TestOutputList for command_lines (9) */
8312 char remotefilename[] = "/test-command";
8315 r = guestfs_upload (g, "test-command", remotefilename);
8320 char path[] = "/test-command";
8323 r = guestfs_chmod (g, 493, path);
8328 char arguments_0[] = "/test-command";
8329 char arguments_1[] = "10";
8330 char *arguments[] = {
8338 r = guestfs_command_lines (g, arguments);
8342 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8347 char expected[] = "Result10-1";
8348 if (strcmp (r[0], expected) != 0) {
8349 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8354 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8359 char expected[] = "Result10-2";
8360 if (strcmp (r[1], expected) != 0) {
8361 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8366 fprintf (stderr, "test_command_lines_9: extra elements returned from command\n");
8370 for (i = 0; r[i] != NULL; ++i)
8377 static int test_command_lines_10_skip (void)
8381 str = getenv ("SKIP_TEST_COMMAND_LINES_10");
8382 if (str && strcmp (str, "1") == 0) return 1;
8383 str = getenv ("SKIP_TEST_COMMAND_LINES");
8384 if (str && strcmp (str, "1") == 0) return 1;
8388 static int test_command_lines_10 (void)
8390 if (test_command_lines_10_skip ()) {
8391 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_10");
8395 /* InitBasicFS for test_command_lines_10: create ext2 on /dev/sda1 */
8397 char device[] = "/dev/sda";
8398 device[5] = devchar;
8401 r = guestfs_blockdev_setrw (g, device);
8408 r = guestfs_umount_all (g);
8415 r = guestfs_lvm_remove_all (g);
8420 char device[] = "/dev/sda";
8421 device[5] = devchar;
8422 char lines_0[] = ",";
8429 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8434 char fstype[] = "ext2";
8435 char device[] = "/dev/sda1";
8436 device[5] = devchar;
8439 r = guestfs_mkfs (g, fstype, device);
8444 char device[] = "/dev/sda1";
8445 device[5] = devchar;
8446 char mountpoint[] = "/";
8449 r = guestfs_mount (g, device, mountpoint);
8453 /* TestOutputList for command_lines (10) */
8455 char remotefilename[] = "/test-command";
8458 r = guestfs_upload (g, "test-command", remotefilename);
8463 char path[] = "/test-command";
8466 r = guestfs_chmod (g, 493, path);
8471 char arguments_0[] = "/test-command";
8472 char arguments_1[] = "11";
8473 char *arguments[] = {
8481 r = guestfs_command_lines (g, arguments);
8485 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
8490 char expected[] = "Result11-1";
8491 if (strcmp (r[0], expected) != 0) {
8492 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8497 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
8502 char expected[] = "Result11-2";
8503 if (strcmp (r[1], expected) != 0) {
8504 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8509 fprintf (stderr, "test_command_lines_10: extra elements returned from command\n");
8513 for (i = 0; r[i] != NULL; ++i)
8520 static int test_command_0_skip (void)
8524 str = getenv ("SKIP_TEST_COMMAND_0");
8525 if (str && strcmp (str, "1") == 0) return 1;
8526 str = getenv ("SKIP_TEST_COMMAND");
8527 if (str && strcmp (str, "1") == 0) return 1;
8531 static int test_command_0 (void)
8533 if (test_command_0_skip ()) {
8534 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_0");
8538 /* InitBasicFS for test_command_0: create ext2 on /dev/sda1 */
8540 char device[] = "/dev/sda";
8541 device[5] = devchar;
8544 r = guestfs_blockdev_setrw (g, device);
8551 r = guestfs_umount_all (g);
8558 r = guestfs_lvm_remove_all (g);
8563 char device[] = "/dev/sda";
8564 device[5] = devchar;
8565 char lines_0[] = ",";
8572 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8577 char fstype[] = "ext2";
8578 char device[] = "/dev/sda1";
8579 device[5] = devchar;
8582 r = guestfs_mkfs (g, fstype, device);
8587 char device[] = "/dev/sda1";
8588 device[5] = devchar;
8589 char mountpoint[] = "/";
8592 r = guestfs_mount (g, device, mountpoint);
8596 /* TestOutput for command (0) */
8597 char expected[] = "Result1";
8599 char remotefilename[] = "/test-command";
8602 r = guestfs_upload (g, "test-command", remotefilename);
8607 char path[] = "/test-command";
8610 r = guestfs_chmod (g, 493, path);
8615 char arguments_0[] = "/test-command";
8616 char arguments_1[] = "1";
8617 char *arguments[] = {
8624 r = guestfs_command (g, arguments);
8627 if (strcmp (r, expected) != 0) {
8628 fprintf (stderr, "test_command_0: expected \"%s\" but got \"%s\"\n", expected, r);
8636 static int test_command_1_skip (void)
8640 str = getenv ("SKIP_TEST_COMMAND_1");
8641 if (str && strcmp (str, "1") == 0) return 1;
8642 str = getenv ("SKIP_TEST_COMMAND");
8643 if (str && strcmp (str, "1") == 0) return 1;
8647 static int test_command_1 (void)
8649 if (test_command_1_skip ()) {
8650 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_1");
8654 /* InitBasicFS for test_command_1: create ext2 on /dev/sda1 */
8656 char device[] = "/dev/sda";
8657 device[5] = devchar;
8660 r = guestfs_blockdev_setrw (g, device);
8667 r = guestfs_umount_all (g);
8674 r = guestfs_lvm_remove_all (g);
8679 char device[] = "/dev/sda";
8680 device[5] = devchar;
8681 char lines_0[] = ",";
8688 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8693 char fstype[] = "ext2";
8694 char device[] = "/dev/sda1";
8695 device[5] = devchar;
8698 r = guestfs_mkfs (g, fstype, device);
8703 char device[] = "/dev/sda1";
8704 device[5] = devchar;
8705 char mountpoint[] = "/";
8708 r = guestfs_mount (g, device, mountpoint);
8712 /* TestOutput for command (1) */
8713 char expected[] = "Result2\n";
8715 char remotefilename[] = "/test-command";
8718 r = guestfs_upload (g, "test-command", remotefilename);
8723 char path[] = "/test-command";
8726 r = guestfs_chmod (g, 493, path);
8731 char arguments_0[] = "/test-command";
8732 char arguments_1[] = "2";
8733 char *arguments[] = {
8740 r = guestfs_command (g, arguments);
8743 if (strcmp (r, expected) != 0) {
8744 fprintf (stderr, "test_command_1: expected \"%s\" but got \"%s\"\n", expected, r);
8752 static int test_command_2_skip (void)
8756 str = getenv ("SKIP_TEST_COMMAND_2");
8757 if (str && strcmp (str, "1") == 0) return 1;
8758 str = getenv ("SKIP_TEST_COMMAND");
8759 if (str && strcmp (str, "1") == 0) return 1;
8763 static int test_command_2 (void)
8765 if (test_command_2_skip ()) {
8766 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_2");
8770 /* InitBasicFS for test_command_2: create ext2 on /dev/sda1 */
8772 char device[] = "/dev/sda";
8773 device[5] = devchar;
8776 r = guestfs_blockdev_setrw (g, device);
8783 r = guestfs_umount_all (g);
8790 r = guestfs_lvm_remove_all (g);
8795 char device[] = "/dev/sda";
8796 device[5] = devchar;
8797 char lines_0[] = ",";
8804 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8809 char fstype[] = "ext2";
8810 char device[] = "/dev/sda1";
8811 device[5] = devchar;
8814 r = guestfs_mkfs (g, fstype, device);
8819 char device[] = "/dev/sda1";
8820 device[5] = devchar;
8821 char mountpoint[] = "/";
8824 r = guestfs_mount (g, device, mountpoint);
8828 /* TestOutput for command (2) */
8829 char expected[] = "\nResult3";
8831 char remotefilename[] = "/test-command";
8834 r = guestfs_upload (g, "test-command", remotefilename);
8839 char path[] = "/test-command";
8842 r = guestfs_chmod (g, 493, path);
8847 char arguments_0[] = "/test-command";
8848 char arguments_1[] = "3";
8849 char *arguments[] = {
8856 r = guestfs_command (g, arguments);
8859 if (strcmp (r, expected) != 0) {
8860 fprintf (stderr, "test_command_2: expected \"%s\" but got \"%s\"\n", expected, r);
8868 static int test_command_3_skip (void)
8872 str = getenv ("SKIP_TEST_COMMAND_3");
8873 if (str && strcmp (str, "1") == 0) return 1;
8874 str = getenv ("SKIP_TEST_COMMAND");
8875 if (str && strcmp (str, "1") == 0) return 1;
8879 static int test_command_3 (void)
8881 if (test_command_3_skip ()) {
8882 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_3");
8886 /* InitBasicFS for test_command_3: create ext2 on /dev/sda1 */
8888 char device[] = "/dev/sda";
8889 device[5] = devchar;
8892 r = guestfs_blockdev_setrw (g, device);
8899 r = guestfs_umount_all (g);
8906 r = guestfs_lvm_remove_all (g);
8911 char device[] = "/dev/sda";
8912 device[5] = devchar;
8913 char lines_0[] = ",";
8920 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8925 char fstype[] = "ext2";
8926 char device[] = "/dev/sda1";
8927 device[5] = devchar;
8930 r = guestfs_mkfs (g, fstype, device);
8935 char device[] = "/dev/sda1";
8936 device[5] = devchar;
8937 char mountpoint[] = "/";
8940 r = guestfs_mount (g, device, mountpoint);
8944 /* TestOutput for command (3) */
8945 char expected[] = "\nResult4\n";
8947 char remotefilename[] = "/test-command";
8950 r = guestfs_upload (g, "test-command", remotefilename);
8955 char path[] = "/test-command";
8958 r = guestfs_chmod (g, 493, path);
8963 char arguments_0[] = "/test-command";
8964 char arguments_1[] = "4";
8965 char *arguments[] = {
8972 r = guestfs_command (g, arguments);
8975 if (strcmp (r, expected) != 0) {
8976 fprintf (stderr, "test_command_3: expected \"%s\" but got \"%s\"\n", expected, r);
8984 static int test_command_4_skip (void)
8988 str = getenv ("SKIP_TEST_COMMAND_4");
8989 if (str && strcmp (str, "1") == 0) return 1;
8990 str = getenv ("SKIP_TEST_COMMAND");
8991 if (str && strcmp (str, "1") == 0) return 1;
8995 static int test_command_4 (void)
8997 if (test_command_4_skip ()) {
8998 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_4");
9002 /* InitBasicFS for test_command_4: create ext2 on /dev/sda1 */
9004 char device[] = "/dev/sda";
9005 device[5] = devchar;
9008 r = guestfs_blockdev_setrw (g, device);
9015 r = guestfs_umount_all (g);
9022 r = guestfs_lvm_remove_all (g);
9027 char device[] = "/dev/sda";
9028 device[5] = devchar;
9029 char lines_0[] = ",";
9036 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9041 char fstype[] = "ext2";
9042 char device[] = "/dev/sda1";
9043 device[5] = devchar;
9046 r = guestfs_mkfs (g, fstype, device);
9051 char device[] = "/dev/sda1";
9052 device[5] = devchar;
9053 char mountpoint[] = "/";
9056 r = guestfs_mount (g, device, mountpoint);
9060 /* TestOutput for command (4) */
9061 char expected[] = "\nResult5\n\n";
9063 char remotefilename[] = "/test-command";
9066 r = guestfs_upload (g, "test-command", remotefilename);
9071 char path[] = "/test-command";
9074 r = guestfs_chmod (g, 493, path);
9079 char arguments_0[] = "/test-command";
9080 char arguments_1[] = "5";
9081 char *arguments[] = {
9088 r = guestfs_command (g, arguments);
9091 if (strcmp (r, expected) != 0) {
9092 fprintf (stderr, "test_command_4: expected \"%s\" but got \"%s\"\n", expected, r);
9100 static int test_command_5_skip (void)
9104 str = getenv ("SKIP_TEST_COMMAND_5");
9105 if (str && strcmp (str, "1") == 0) return 1;
9106 str = getenv ("SKIP_TEST_COMMAND");
9107 if (str && strcmp (str, "1") == 0) return 1;
9111 static int test_command_5 (void)
9113 if (test_command_5_skip ()) {
9114 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_5");
9118 /* InitBasicFS for test_command_5: create ext2 on /dev/sda1 */
9120 char device[] = "/dev/sda";
9121 device[5] = devchar;
9124 r = guestfs_blockdev_setrw (g, device);
9131 r = guestfs_umount_all (g);
9138 r = guestfs_lvm_remove_all (g);
9143 char device[] = "/dev/sda";
9144 device[5] = devchar;
9145 char lines_0[] = ",";
9152 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9157 char fstype[] = "ext2";
9158 char device[] = "/dev/sda1";
9159 device[5] = devchar;
9162 r = guestfs_mkfs (g, fstype, device);
9167 char device[] = "/dev/sda1";
9168 device[5] = devchar;
9169 char mountpoint[] = "/";
9172 r = guestfs_mount (g, device, mountpoint);
9176 /* TestOutput for command (5) */
9177 char expected[] = "\n\nResult6\n\n";
9179 char remotefilename[] = "/test-command";
9182 r = guestfs_upload (g, "test-command", remotefilename);
9187 char path[] = "/test-command";
9190 r = guestfs_chmod (g, 493, path);
9195 char arguments_0[] = "/test-command";
9196 char arguments_1[] = "6";
9197 char *arguments[] = {
9204 r = guestfs_command (g, arguments);
9207 if (strcmp (r, expected) != 0) {
9208 fprintf (stderr, "test_command_5: expected \"%s\" but got \"%s\"\n", expected, r);
9216 static int test_command_6_skip (void)
9220 str = getenv ("SKIP_TEST_COMMAND_6");
9221 if (str && strcmp (str, "1") == 0) return 1;
9222 str = getenv ("SKIP_TEST_COMMAND");
9223 if (str && strcmp (str, "1") == 0) return 1;
9227 static int test_command_6 (void)
9229 if (test_command_6_skip ()) {
9230 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_6");
9234 /* InitBasicFS for test_command_6: create ext2 on /dev/sda1 */
9236 char device[] = "/dev/sda";
9237 device[5] = devchar;
9240 r = guestfs_blockdev_setrw (g, device);
9247 r = guestfs_umount_all (g);
9254 r = guestfs_lvm_remove_all (g);
9259 char device[] = "/dev/sda";
9260 device[5] = devchar;
9261 char lines_0[] = ",";
9268 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9273 char fstype[] = "ext2";
9274 char device[] = "/dev/sda1";
9275 device[5] = devchar;
9278 r = guestfs_mkfs (g, fstype, device);
9283 char device[] = "/dev/sda1";
9284 device[5] = devchar;
9285 char mountpoint[] = "/";
9288 r = guestfs_mount (g, device, mountpoint);
9292 /* TestOutput for command (6) */
9293 char expected[] = "";
9295 char remotefilename[] = "/test-command";
9298 r = guestfs_upload (g, "test-command", remotefilename);
9303 char path[] = "/test-command";
9306 r = guestfs_chmod (g, 493, path);
9311 char arguments_0[] = "/test-command";
9312 char arguments_1[] = "7";
9313 char *arguments[] = {
9320 r = guestfs_command (g, arguments);
9323 if (strcmp (r, expected) != 0) {
9324 fprintf (stderr, "test_command_6: expected \"%s\" but got \"%s\"\n", expected, r);
9332 static int test_command_7_skip (void)
9336 str = getenv ("SKIP_TEST_COMMAND_7");
9337 if (str && strcmp (str, "1") == 0) return 1;
9338 str = getenv ("SKIP_TEST_COMMAND");
9339 if (str && strcmp (str, "1") == 0) return 1;
9343 static int test_command_7 (void)
9345 if (test_command_7_skip ()) {
9346 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_7");
9350 /* InitBasicFS for test_command_7: create ext2 on /dev/sda1 */
9352 char device[] = "/dev/sda";
9353 device[5] = devchar;
9356 r = guestfs_blockdev_setrw (g, device);
9363 r = guestfs_umount_all (g);
9370 r = guestfs_lvm_remove_all (g);
9375 char device[] = "/dev/sda";
9376 device[5] = devchar;
9377 char lines_0[] = ",";
9384 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9389 char fstype[] = "ext2";
9390 char device[] = "/dev/sda1";
9391 device[5] = devchar;
9394 r = guestfs_mkfs (g, fstype, device);
9399 char device[] = "/dev/sda1";
9400 device[5] = devchar;
9401 char mountpoint[] = "/";
9404 r = guestfs_mount (g, device, mountpoint);
9408 /* TestOutput for command (7) */
9409 char expected[] = "\n";
9411 char remotefilename[] = "/test-command";
9414 r = guestfs_upload (g, "test-command", remotefilename);
9419 char path[] = "/test-command";
9422 r = guestfs_chmod (g, 493, path);
9427 char arguments_0[] = "/test-command";
9428 char arguments_1[] = "8";
9429 char *arguments[] = {
9436 r = guestfs_command (g, arguments);
9439 if (strcmp (r, expected) != 0) {
9440 fprintf (stderr, "test_command_7: expected \"%s\" but got \"%s\"\n", expected, r);
9448 static int test_command_8_skip (void)
9452 str = getenv ("SKIP_TEST_COMMAND_8");
9453 if (str && strcmp (str, "1") == 0) return 1;
9454 str = getenv ("SKIP_TEST_COMMAND");
9455 if (str && strcmp (str, "1") == 0) return 1;
9459 static int test_command_8 (void)
9461 if (test_command_8_skip ()) {
9462 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_8");
9466 /* InitBasicFS for test_command_8: create ext2 on /dev/sda1 */
9468 char device[] = "/dev/sda";
9469 device[5] = devchar;
9472 r = guestfs_blockdev_setrw (g, device);
9479 r = guestfs_umount_all (g);
9486 r = guestfs_lvm_remove_all (g);
9491 char device[] = "/dev/sda";
9492 device[5] = devchar;
9493 char lines_0[] = ",";
9500 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9505 char fstype[] = "ext2";
9506 char device[] = "/dev/sda1";
9507 device[5] = devchar;
9510 r = guestfs_mkfs (g, fstype, device);
9515 char device[] = "/dev/sda1";
9516 device[5] = devchar;
9517 char mountpoint[] = "/";
9520 r = guestfs_mount (g, device, mountpoint);
9524 /* TestOutput for command (8) */
9525 char expected[] = "\n\n";
9527 char remotefilename[] = "/test-command";
9530 r = guestfs_upload (g, "test-command", remotefilename);
9535 char path[] = "/test-command";
9538 r = guestfs_chmod (g, 493, path);
9543 char arguments_0[] = "/test-command";
9544 char arguments_1[] = "9";
9545 char *arguments[] = {
9552 r = guestfs_command (g, arguments);
9555 if (strcmp (r, expected) != 0) {
9556 fprintf (stderr, "test_command_8: expected \"%s\" but got \"%s\"\n", expected, r);
9564 static int test_command_9_skip (void)
9568 str = getenv ("SKIP_TEST_COMMAND_9");
9569 if (str && strcmp (str, "1") == 0) return 1;
9570 str = getenv ("SKIP_TEST_COMMAND");
9571 if (str && strcmp (str, "1") == 0) return 1;
9575 static int test_command_9 (void)
9577 if (test_command_9_skip ()) {
9578 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_9");
9582 /* InitBasicFS for test_command_9: create ext2 on /dev/sda1 */
9584 char device[] = "/dev/sda";
9585 device[5] = devchar;
9588 r = guestfs_blockdev_setrw (g, device);
9595 r = guestfs_umount_all (g);
9602 r = guestfs_lvm_remove_all (g);
9607 char device[] = "/dev/sda";
9608 device[5] = devchar;
9609 char lines_0[] = ",";
9616 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9621 char fstype[] = "ext2";
9622 char device[] = "/dev/sda1";
9623 device[5] = devchar;
9626 r = guestfs_mkfs (g, fstype, device);
9631 char device[] = "/dev/sda1";
9632 device[5] = devchar;
9633 char mountpoint[] = "/";
9636 r = guestfs_mount (g, device, mountpoint);
9640 /* TestOutput for command (9) */
9641 char expected[] = "Result10-1\nResult10-2\n";
9643 char remotefilename[] = "/test-command";
9646 r = guestfs_upload (g, "test-command", remotefilename);
9651 char path[] = "/test-command";
9654 r = guestfs_chmod (g, 493, path);
9659 char arguments_0[] = "/test-command";
9660 char arguments_1[] = "10";
9661 char *arguments[] = {
9668 r = guestfs_command (g, arguments);
9671 if (strcmp (r, expected) != 0) {
9672 fprintf (stderr, "test_command_9: expected \"%s\" but got \"%s\"\n", expected, r);
9680 static int test_command_10_skip (void)
9684 str = getenv ("SKIP_TEST_COMMAND_10");
9685 if (str && strcmp (str, "1") == 0) return 1;
9686 str = getenv ("SKIP_TEST_COMMAND");
9687 if (str && strcmp (str, "1") == 0) return 1;
9691 static int test_command_10 (void)
9693 if (test_command_10_skip ()) {
9694 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_10");
9698 /* InitBasicFS for test_command_10: create ext2 on /dev/sda1 */
9700 char device[] = "/dev/sda";
9701 device[5] = devchar;
9704 r = guestfs_blockdev_setrw (g, device);
9711 r = guestfs_umount_all (g);
9718 r = guestfs_lvm_remove_all (g);
9723 char device[] = "/dev/sda";
9724 device[5] = devchar;
9725 char lines_0[] = ",";
9732 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9737 char fstype[] = "ext2";
9738 char device[] = "/dev/sda1";
9739 device[5] = devchar;
9742 r = guestfs_mkfs (g, fstype, device);
9747 char device[] = "/dev/sda1";
9748 device[5] = devchar;
9749 char mountpoint[] = "/";
9752 r = guestfs_mount (g, device, mountpoint);
9756 /* TestOutput for command (10) */
9757 char expected[] = "Result11-1\nResult11-2";
9759 char remotefilename[] = "/test-command";
9762 r = guestfs_upload (g, "test-command", remotefilename);
9767 char path[] = "/test-command";
9770 r = guestfs_chmod (g, 493, path);
9775 char arguments_0[] = "/test-command";
9776 char arguments_1[] = "11";
9777 char *arguments[] = {
9784 r = guestfs_command (g, arguments);
9787 if (strcmp (r, expected) != 0) {
9788 fprintf (stderr, "test_command_10: expected \"%s\" but got \"%s\"\n", expected, r);
9796 static int test_command_11_skip (void)
9800 str = getenv ("SKIP_TEST_COMMAND_11");
9801 if (str && strcmp (str, "1") == 0) return 1;
9802 str = getenv ("SKIP_TEST_COMMAND");
9803 if (str && strcmp (str, "1") == 0) return 1;
9807 static int test_command_11 (void)
9809 if (test_command_11_skip ()) {
9810 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_11");
9814 /* InitBasicFS for test_command_11: create ext2 on /dev/sda1 */
9816 char device[] = "/dev/sda";
9817 device[5] = devchar;
9820 r = guestfs_blockdev_setrw (g, device);
9827 r = guestfs_umount_all (g);
9834 r = guestfs_lvm_remove_all (g);
9839 char device[] = "/dev/sda";
9840 device[5] = devchar;
9841 char lines_0[] = ",";
9848 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9853 char fstype[] = "ext2";
9854 char device[] = "/dev/sda1";
9855 device[5] = devchar;
9858 r = guestfs_mkfs (g, fstype, device);
9863 char device[] = "/dev/sda1";
9864 device[5] = devchar;
9865 char mountpoint[] = "/";
9868 r = guestfs_mount (g, device, mountpoint);
9872 /* TestLastFail for command (11) */
9874 char remotefilename[] = "/test-command";
9877 r = guestfs_upload (g, "test-command", remotefilename);
9882 char path[] = "/test-command";
9885 r = guestfs_chmod (g, 493, path);
9890 char arguments_0[] = "/test-command";
9891 char *arguments[] = {
9897 r = guestfs_command (g, arguments);
9905 static int test_file_0_skip (void)
9909 str = getenv ("SKIP_TEST_FILE_0");
9910 if (str && strcmp (str, "1") == 0) return 1;
9911 str = getenv ("SKIP_TEST_FILE");
9912 if (str && strcmp (str, "1") == 0) return 1;
9916 static int test_file_0 (void)
9918 if (test_file_0_skip ()) {
9919 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_0");
9923 /* InitBasicFS for test_file_0: create ext2 on /dev/sda1 */
9925 char device[] = "/dev/sda";
9926 device[5] = devchar;
9929 r = guestfs_blockdev_setrw (g, device);
9936 r = guestfs_umount_all (g);
9943 r = guestfs_lvm_remove_all (g);
9948 char device[] = "/dev/sda";
9949 device[5] = devchar;
9950 char lines_0[] = ",";
9957 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9962 char fstype[] = "ext2";
9963 char device[] = "/dev/sda1";
9964 device[5] = devchar;
9967 r = guestfs_mkfs (g, fstype, device);
9972 char device[] = "/dev/sda1";
9973 device[5] = devchar;
9974 char mountpoint[] = "/";
9977 r = guestfs_mount (g, device, mountpoint);
9981 /* TestOutput for file (0) */
9982 char expected[] = "empty";
9984 char path[] = "/new";
9987 r = guestfs_touch (g, path);
9992 char path[] = "/new";
9995 r = guestfs_file (g, path);
9998 if (strcmp (r, expected) != 0) {
9999 fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
10007 static int test_file_1_skip (void)
10011 str = getenv ("SKIP_TEST_FILE_1");
10012 if (str && strcmp (str, "1") == 0) return 1;
10013 str = getenv ("SKIP_TEST_FILE");
10014 if (str && strcmp (str, "1") == 0) return 1;
10018 static int test_file_1 (void)
10020 if (test_file_1_skip ()) {
10021 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_1");
10025 /* InitBasicFS for test_file_1: create ext2 on /dev/sda1 */
10027 char device[] = "/dev/sda";
10028 device[5] = devchar;
10030 suppress_error = 0;
10031 r = guestfs_blockdev_setrw (g, device);
10037 suppress_error = 0;
10038 r = guestfs_umount_all (g);
10044 suppress_error = 0;
10045 r = guestfs_lvm_remove_all (g);
10050 char device[] = "/dev/sda";
10051 device[5] = devchar;
10052 char lines_0[] = ",";
10058 suppress_error = 0;
10059 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10064 char fstype[] = "ext2";
10065 char device[] = "/dev/sda1";
10066 device[5] = devchar;
10068 suppress_error = 0;
10069 r = guestfs_mkfs (g, fstype, device);
10074 char device[] = "/dev/sda1";
10075 device[5] = devchar;
10076 char mountpoint[] = "/";
10078 suppress_error = 0;
10079 r = guestfs_mount (g, device, mountpoint);
10083 /* TestOutput for file (1) */
10084 char expected[] = "ASCII text";
10086 char path[] = "/new";
10087 char content[] = "some content\n";
10089 suppress_error = 0;
10090 r = guestfs_write_file (g, path, content, 0);
10095 char path[] = "/new";
10097 suppress_error = 0;
10098 r = guestfs_file (g, path);
10101 if (strcmp (r, expected) != 0) {
10102 fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
10110 static int test_file_2_skip (void)
10114 str = getenv ("SKIP_TEST_FILE_2");
10115 if (str && strcmp (str, "1") == 0) return 1;
10116 str = getenv ("SKIP_TEST_FILE");
10117 if (str && strcmp (str, "1") == 0) return 1;
10121 static int test_file_2 (void)
10123 if (test_file_2_skip ()) {
10124 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_2");
10128 /* InitBasicFS for test_file_2: create ext2 on /dev/sda1 */
10130 char device[] = "/dev/sda";
10131 device[5] = devchar;
10133 suppress_error = 0;
10134 r = guestfs_blockdev_setrw (g, device);
10140 suppress_error = 0;
10141 r = guestfs_umount_all (g);
10147 suppress_error = 0;
10148 r = guestfs_lvm_remove_all (g);
10153 char device[] = "/dev/sda";
10154 device[5] = devchar;
10155 char lines_0[] = ",";
10161 suppress_error = 0;
10162 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10167 char fstype[] = "ext2";
10168 char device[] = "/dev/sda1";
10169 device[5] = devchar;
10171 suppress_error = 0;
10172 r = guestfs_mkfs (g, fstype, device);
10177 char device[] = "/dev/sda1";
10178 device[5] = devchar;
10179 char mountpoint[] = "/";
10181 suppress_error = 0;
10182 r = guestfs_mount (g, device, mountpoint);
10186 /* TestLastFail for file (2) */
10188 char path[] = "/nofile";
10190 suppress_error = 1;
10191 r = guestfs_file (g, path);
10199 static int test_umount_all_0_skip (void)
10203 str = getenv ("SKIP_TEST_UMOUNT_ALL_0");
10204 if (str && strcmp (str, "1") == 0) return 1;
10205 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10206 if (str && strcmp (str, "1") == 0) return 1;
10210 static int test_umount_all_0 (void)
10212 if (test_umount_all_0_skip ()) {
10213 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_0");
10217 /* InitBasicFS for test_umount_all_0: create ext2 on /dev/sda1 */
10219 char device[] = "/dev/sda";
10220 device[5] = devchar;
10222 suppress_error = 0;
10223 r = guestfs_blockdev_setrw (g, device);
10229 suppress_error = 0;
10230 r = guestfs_umount_all (g);
10236 suppress_error = 0;
10237 r = guestfs_lvm_remove_all (g);
10242 char device[] = "/dev/sda";
10243 device[5] = devchar;
10244 char lines_0[] = ",";
10250 suppress_error = 0;
10251 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10256 char fstype[] = "ext2";
10257 char device[] = "/dev/sda1";
10258 device[5] = devchar;
10260 suppress_error = 0;
10261 r = guestfs_mkfs (g, fstype, device);
10266 char device[] = "/dev/sda1";
10267 device[5] = devchar;
10268 char mountpoint[] = "/";
10270 suppress_error = 0;
10271 r = guestfs_mount (g, device, mountpoint);
10275 /* TestOutputList for umount_all (0) */
10278 suppress_error = 0;
10279 r = guestfs_umount_all (g);
10286 suppress_error = 0;
10287 r = guestfs_mounts (g);
10290 if (r[0] != NULL) {
10291 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
10295 for (i = 0; r[i] != NULL; ++i)
10302 static int test_umount_all_1_skip (void)
10306 str = getenv ("SKIP_TEST_UMOUNT_ALL_1");
10307 if (str && strcmp (str, "1") == 0) return 1;
10308 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10309 if (str && strcmp (str, "1") == 0) return 1;
10313 static int test_umount_all_1 (void)
10315 if (test_umount_all_1_skip ()) {
10316 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_1");
10320 /* InitNone|InitEmpty for test_umount_all_1 */
10322 char device[] = "/dev/sda";
10323 device[5] = devchar;
10325 suppress_error = 0;
10326 r = guestfs_blockdev_setrw (g, device);
10332 suppress_error = 0;
10333 r = guestfs_umount_all (g);
10339 suppress_error = 0;
10340 r = guestfs_lvm_remove_all (g);
10344 /* TestOutputList for umount_all (1) */
10346 char device[] = "/dev/sda";
10347 device[5] = devchar;
10348 char lines_0[] = ",10";
10349 char lines_1[] = ",20";
10350 char lines_2[] = ",";
10358 suppress_error = 0;
10359 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10364 char fstype[] = "ext2";
10365 char device[] = "/dev/sda1";
10366 device[5] = devchar;
10368 suppress_error = 0;
10369 r = guestfs_mkfs (g, fstype, device);
10374 char fstype[] = "ext2";
10375 char device[] = "/dev/sda2";
10376 device[5] = devchar;
10378 suppress_error = 0;
10379 r = guestfs_mkfs (g, fstype, device);
10384 char fstype[] = "ext2";
10385 char device[] = "/dev/sda3";
10386 device[5] = devchar;
10388 suppress_error = 0;
10389 r = guestfs_mkfs (g, fstype, device);
10394 char device[] = "/dev/sda1";
10395 device[5] = devchar;
10396 char mountpoint[] = "/";
10398 suppress_error = 0;
10399 r = guestfs_mount (g, device, mountpoint);
10404 char path[] = "/mp1";
10406 suppress_error = 0;
10407 r = guestfs_mkdir (g, path);
10412 char device[] = "/dev/sda2";
10413 device[5] = devchar;
10414 char mountpoint[] = "/mp1";
10416 suppress_error = 0;
10417 r = guestfs_mount (g, device, mountpoint);
10422 char path[] = "/mp1/mp2";
10424 suppress_error = 0;
10425 r = guestfs_mkdir (g, path);
10430 char device[] = "/dev/sda3";
10431 device[5] = devchar;
10432 char mountpoint[] = "/mp1/mp2";
10434 suppress_error = 0;
10435 r = guestfs_mount (g, device, mountpoint);
10440 char path[] = "/mp1/mp2/mp3";
10442 suppress_error = 0;
10443 r = guestfs_mkdir (g, path);
10449 suppress_error = 0;
10450 r = guestfs_umount_all (g);
10457 suppress_error = 0;
10458 r = guestfs_mounts (g);
10461 if (r[0] != NULL) {
10462 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
10466 for (i = 0; r[i] != NULL; ++i)
10473 static int test_mounts_0_skip (void)
10477 str = getenv ("SKIP_TEST_MOUNTS_0");
10478 if (str && strcmp (str, "1") == 0) return 1;
10479 str = getenv ("SKIP_TEST_MOUNTS");
10480 if (str && strcmp (str, "1") == 0) return 1;
10484 static int test_mounts_0 (void)
10486 if (test_mounts_0_skip ()) {
10487 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mounts_0");
10491 /* InitBasicFS for test_mounts_0: create ext2 on /dev/sda1 */
10493 char device[] = "/dev/sda";
10494 device[5] = devchar;
10496 suppress_error = 0;
10497 r = guestfs_blockdev_setrw (g, device);
10503 suppress_error = 0;
10504 r = guestfs_umount_all (g);
10510 suppress_error = 0;
10511 r = guestfs_lvm_remove_all (g);
10516 char device[] = "/dev/sda";
10517 device[5] = devchar;
10518 char lines_0[] = ",";
10524 suppress_error = 0;
10525 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10530 char fstype[] = "ext2";
10531 char device[] = "/dev/sda1";
10532 device[5] = devchar;
10534 suppress_error = 0;
10535 r = guestfs_mkfs (g, fstype, device);
10540 char device[] = "/dev/sda1";
10541 device[5] = devchar;
10542 char mountpoint[] = "/";
10544 suppress_error = 0;
10545 r = guestfs_mount (g, device, mountpoint);
10549 /* TestOutputList for mounts (0) */
10553 suppress_error = 0;
10554 r = guestfs_mounts (g);
10558 fprintf (stderr, "test_mounts_0: short list returned from command\n");
10563 char expected[] = "/dev/sda1";
10564 expected[5] = devchar;
10565 if (strcmp (r[0], expected) != 0) {
10566 fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
10570 if (r[1] != NULL) {
10571 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
10575 for (i = 0; r[i] != NULL; ++i)
10582 static int test_umount_0_skip (void)
10586 str = getenv ("SKIP_TEST_UMOUNT_0");
10587 if (str && strcmp (str, "1") == 0) return 1;
10588 str = getenv ("SKIP_TEST_UMOUNT");
10589 if (str && strcmp (str, "1") == 0) return 1;
10593 static int test_umount_0 (void)
10595 if (test_umount_0_skip ()) {
10596 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_0");
10600 /* InitNone|InitEmpty for test_umount_0 */
10602 char device[] = "/dev/sda";
10603 device[5] = devchar;
10605 suppress_error = 0;
10606 r = guestfs_blockdev_setrw (g, device);
10612 suppress_error = 0;
10613 r = guestfs_umount_all (g);
10619 suppress_error = 0;
10620 r = guestfs_lvm_remove_all (g);
10624 /* TestOutputList for umount (0) */
10626 char device[] = "/dev/sda";
10627 device[5] = devchar;
10628 char lines_0[] = ",";
10634 suppress_error = 0;
10635 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10640 char fstype[] = "ext2";
10641 char device[] = "/dev/sda1";
10642 device[5] = devchar;
10644 suppress_error = 0;
10645 r = guestfs_mkfs (g, fstype, device);
10650 char device[] = "/dev/sda1";
10651 device[5] = devchar;
10652 char mountpoint[] = "/";
10654 suppress_error = 0;
10655 r = guestfs_mount (g, device, mountpoint);
10662 suppress_error = 0;
10663 r = guestfs_mounts (g);
10667 fprintf (stderr, "test_umount_0: short list returned from command\n");
10672 char expected[] = "/dev/sda1";
10673 expected[5] = devchar;
10674 if (strcmp (r[0], expected) != 0) {
10675 fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
10679 if (r[1] != NULL) {
10680 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
10684 for (i = 0; r[i] != NULL; ++i)
10691 static int test_umount_1_skip (void)
10695 str = getenv ("SKIP_TEST_UMOUNT_1");
10696 if (str && strcmp (str, "1") == 0) return 1;
10697 str = getenv ("SKIP_TEST_UMOUNT");
10698 if (str && strcmp (str, "1") == 0) return 1;
10702 static int test_umount_1 (void)
10704 if (test_umount_1_skip ()) {
10705 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_1");
10709 /* InitNone|InitEmpty for test_umount_1 */
10711 char device[] = "/dev/sda";
10712 device[5] = devchar;
10714 suppress_error = 0;
10715 r = guestfs_blockdev_setrw (g, device);
10721 suppress_error = 0;
10722 r = guestfs_umount_all (g);
10728 suppress_error = 0;
10729 r = guestfs_lvm_remove_all (g);
10733 /* TestOutputList for umount (1) */
10735 char device[] = "/dev/sda";
10736 device[5] = devchar;
10737 char lines_0[] = ",";
10743 suppress_error = 0;
10744 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10749 char fstype[] = "ext2";
10750 char device[] = "/dev/sda1";
10751 device[5] = devchar;
10753 suppress_error = 0;
10754 r = guestfs_mkfs (g, fstype, device);
10759 char device[] = "/dev/sda1";
10760 device[5] = devchar;
10761 char mountpoint[] = "/";
10763 suppress_error = 0;
10764 r = guestfs_mount (g, device, mountpoint);
10769 char pathordevice[] = "/";
10771 suppress_error = 0;
10772 r = guestfs_umount (g, pathordevice);
10779 suppress_error = 0;
10780 r = guestfs_mounts (g);
10783 if (r[0] != NULL) {
10784 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
10788 for (i = 0; r[i] != NULL; ++i)
10795 static int test_write_file_0_skip (void)
10799 str = getenv ("SKIP_TEST_WRITE_FILE_0");
10800 if (str && strcmp (str, "1") == 0) return 1;
10801 str = getenv ("SKIP_TEST_WRITE_FILE");
10802 if (str && strcmp (str, "1") == 0) return 1;
10806 static int test_write_file_0 (void)
10808 if (test_write_file_0_skip ()) {
10809 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_0");
10813 /* InitBasicFS for test_write_file_0: create ext2 on /dev/sda1 */
10815 char device[] = "/dev/sda";
10816 device[5] = devchar;
10818 suppress_error = 0;
10819 r = guestfs_blockdev_setrw (g, device);
10825 suppress_error = 0;
10826 r = guestfs_umount_all (g);
10832 suppress_error = 0;
10833 r = guestfs_lvm_remove_all (g);
10838 char device[] = "/dev/sda";
10839 device[5] = devchar;
10840 char lines_0[] = ",";
10846 suppress_error = 0;
10847 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10852 char fstype[] = "ext2";
10853 char device[] = "/dev/sda1";
10854 device[5] = devchar;
10856 suppress_error = 0;
10857 r = guestfs_mkfs (g, fstype, device);
10862 char device[] = "/dev/sda1";
10863 device[5] = devchar;
10864 char mountpoint[] = "/";
10866 suppress_error = 0;
10867 r = guestfs_mount (g, device, mountpoint);
10871 /* TestOutput for write_file (0) */
10872 char expected[] = "new file contents";
10874 char path[] = "/new";
10875 char content[] = "new file contents";
10877 suppress_error = 0;
10878 r = guestfs_write_file (g, path, content, 0);
10883 char path[] = "/new";
10885 suppress_error = 0;
10886 r = guestfs_cat (g, path);
10889 if (strcmp (r, expected) != 0) {
10890 fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
10898 static int test_write_file_1_skip (void)
10902 str = getenv ("SKIP_TEST_WRITE_FILE_1");
10903 if (str && strcmp (str, "1") == 0) return 1;
10904 str = getenv ("SKIP_TEST_WRITE_FILE");
10905 if (str && strcmp (str, "1") == 0) return 1;
10909 static int test_write_file_1 (void)
10911 if (test_write_file_1_skip ()) {
10912 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_1");
10916 /* InitBasicFS for test_write_file_1: create ext2 on /dev/sda1 */
10918 char device[] = "/dev/sda";
10919 device[5] = devchar;
10921 suppress_error = 0;
10922 r = guestfs_blockdev_setrw (g, device);
10928 suppress_error = 0;
10929 r = guestfs_umount_all (g);
10935 suppress_error = 0;
10936 r = guestfs_lvm_remove_all (g);
10941 char device[] = "/dev/sda";
10942 device[5] = devchar;
10943 char lines_0[] = ",";
10949 suppress_error = 0;
10950 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10955 char fstype[] = "ext2";
10956 char device[] = "/dev/sda1";
10957 device[5] = devchar;
10959 suppress_error = 0;
10960 r = guestfs_mkfs (g, fstype, device);
10965 char device[] = "/dev/sda1";
10966 device[5] = devchar;
10967 char mountpoint[] = "/";
10969 suppress_error = 0;
10970 r = guestfs_mount (g, device, mountpoint);
10974 /* TestOutput for write_file (1) */
10975 char expected[] = "\nnew file contents\n";
10977 char path[] = "/new";
10978 char content[] = "\nnew file contents\n";
10980 suppress_error = 0;
10981 r = guestfs_write_file (g, path, content, 0);
10986 char path[] = "/new";
10988 suppress_error = 0;
10989 r = guestfs_cat (g, path);
10992 if (strcmp (r, expected) != 0) {
10993 fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
11001 static int test_write_file_2_skip (void)
11005 str = getenv ("SKIP_TEST_WRITE_FILE_2");
11006 if (str && strcmp (str, "1") == 0) return 1;
11007 str = getenv ("SKIP_TEST_WRITE_FILE");
11008 if (str && strcmp (str, "1") == 0) return 1;
11012 static int test_write_file_2 (void)
11014 if (test_write_file_2_skip ()) {
11015 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_2");
11019 /* InitBasicFS for test_write_file_2: create ext2 on /dev/sda1 */
11021 char device[] = "/dev/sda";
11022 device[5] = devchar;
11024 suppress_error = 0;
11025 r = guestfs_blockdev_setrw (g, device);
11031 suppress_error = 0;
11032 r = guestfs_umount_all (g);
11038 suppress_error = 0;
11039 r = guestfs_lvm_remove_all (g);
11044 char device[] = "/dev/sda";
11045 device[5] = devchar;
11046 char lines_0[] = ",";
11052 suppress_error = 0;
11053 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11058 char fstype[] = "ext2";
11059 char device[] = "/dev/sda1";
11060 device[5] = devchar;
11062 suppress_error = 0;
11063 r = guestfs_mkfs (g, fstype, device);
11068 char device[] = "/dev/sda1";
11069 device[5] = devchar;
11070 char mountpoint[] = "/";
11072 suppress_error = 0;
11073 r = guestfs_mount (g, device, mountpoint);
11077 /* TestOutput for write_file (2) */
11078 char expected[] = "\n\n";
11080 char path[] = "/new";
11081 char content[] = "\n\n";
11083 suppress_error = 0;
11084 r = guestfs_write_file (g, path, content, 0);
11089 char path[] = "/new";
11091 suppress_error = 0;
11092 r = guestfs_cat (g, path);
11095 if (strcmp (r, expected) != 0) {
11096 fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
11104 static int test_write_file_3_skip (void)
11108 str = getenv ("SKIP_TEST_WRITE_FILE_3");
11109 if (str && strcmp (str, "1") == 0) return 1;
11110 str = getenv ("SKIP_TEST_WRITE_FILE");
11111 if (str && strcmp (str, "1") == 0) return 1;
11115 static int test_write_file_3 (void)
11117 if (test_write_file_3_skip ()) {
11118 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_3");
11122 /* InitBasicFS for test_write_file_3: create ext2 on /dev/sda1 */
11124 char device[] = "/dev/sda";
11125 device[5] = devchar;
11127 suppress_error = 0;
11128 r = guestfs_blockdev_setrw (g, device);
11134 suppress_error = 0;
11135 r = guestfs_umount_all (g);
11141 suppress_error = 0;
11142 r = guestfs_lvm_remove_all (g);
11147 char device[] = "/dev/sda";
11148 device[5] = devchar;
11149 char lines_0[] = ",";
11155 suppress_error = 0;
11156 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11161 char fstype[] = "ext2";
11162 char device[] = "/dev/sda1";
11163 device[5] = devchar;
11165 suppress_error = 0;
11166 r = guestfs_mkfs (g, fstype, device);
11171 char device[] = "/dev/sda1";
11172 device[5] = devchar;
11173 char mountpoint[] = "/";
11175 suppress_error = 0;
11176 r = guestfs_mount (g, device, mountpoint);
11180 /* TestOutput for write_file (3) */
11181 char expected[] = "";
11183 char path[] = "/new";
11184 char content[] = "";
11186 suppress_error = 0;
11187 r = guestfs_write_file (g, path, content, 0);
11192 char path[] = "/new";
11194 suppress_error = 0;
11195 r = guestfs_cat (g, path);
11198 if (strcmp (r, expected) != 0) {
11199 fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
11207 static int test_write_file_4_skip (void)
11211 str = getenv ("SKIP_TEST_WRITE_FILE_4");
11212 if (str && strcmp (str, "1") == 0) return 1;
11213 str = getenv ("SKIP_TEST_WRITE_FILE");
11214 if (str && strcmp (str, "1") == 0) return 1;
11218 static int test_write_file_4 (void)
11220 if (test_write_file_4_skip ()) {
11221 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_4");
11225 /* InitBasicFS for test_write_file_4: create ext2 on /dev/sda1 */
11227 char device[] = "/dev/sda";
11228 device[5] = devchar;
11230 suppress_error = 0;
11231 r = guestfs_blockdev_setrw (g, device);
11237 suppress_error = 0;
11238 r = guestfs_umount_all (g);
11244 suppress_error = 0;
11245 r = guestfs_lvm_remove_all (g);
11250 char device[] = "/dev/sda";
11251 device[5] = devchar;
11252 char lines_0[] = ",";
11258 suppress_error = 0;
11259 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11264 char fstype[] = "ext2";
11265 char device[] = "/dev/sda1";
11266 device[5] = devchar;
11268 suppress_error = 0;
11269 r = guestfs_mkfs (g, fstype, device);
11274 char device[] = "/dev/sda1";
11275 device[5] = devchar;
11276 char mountpoint[] = "/";
11278 suppress_error = 0;
11279 r = guestfs_mount (g, device, mountpoint);
11283 /* TestOutput for write_file (4) */
11284 char expected[] = "\n\n\n";
11286 char path[] = "/new";
11287 char content[] = "\n\n\n";
11289 suppress_error = 0;
11290 r = guestfs_write_file (g, path, content, 0);
11295 char path[] = "/new";
11297 suppress_error = 0;
11298 r = guestfs_cat (g, path);
11301 if (strcmp (r, expected) != 0) {
11302 fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
11310 static int test_write_file_5_skip (void)
11314 str = getenv ("SKIP_TEST_WRITE_FILE_5");
11315 if (str && strcmp (str, "1") == 0) return 1;
11316 str = getenv ("SKIP_TEST_WRITE_FILE");
11317 if (str && strcmp (str, "1") == 0) return 1;
11321 static int test_write_file_5 (void)
11323 if (test_write_file_5_skip ()) {
11324 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_5");
11328 /* InitBasicFS for test_write_file_5: create ext2 on /dev/sda1 */
11330 char device[] = "/dev/sda";
11331 device[5] = devchar;
11333 suppress_error = 0;
11334 r = guestfs_blockdev_setrw (g, device);
11340 suppress_error = 0;
11341 r = guestfs_umount_all (g);
11347 suppress_error = 0;
11348 r = guestfs_lvm_remove_all (g);
11353 char device[] = "/dev/sda";
11354 device[5] = devchar;
11355 char lines_0[] = ",";
11361 suppress_error = 0;
11362 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11367 char fstype[] = "ext2";
11368 char device[] = "/dev/sda1";
11369 device[5] = devchar;
11371 suppress_error = 0;
11372 r = guestfs_mkfs (g, fstype, device);
11377 char device[] = "/dev/sda1";
11378 device[5] = devchar;
11379 char mountpoint[] = "/";
11381 suppress_error = 0;
11382 r = guestfs_mount (g, device, mountpoint);
11386 /* TestOutput for write_file (5) */
11387 char expected[] = "\n";
11389 char path[] = "/new";
11390 char content[] = "\n";
11392 suppress_error = 0;
11393 r = guestfs_write_file (g, path, content, 0);
11398 char path[] = "/new";
11400 suppress_error = 0;
11401 r = guestfs_cat (g, path);
11404 if (strcmp (r, expected) != 0) {
11405 fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
11413 static int test_mkfs_0_skip (void)
11417 str = getenv ("SKIP_TEST_MKFS_0");
11418 if (str && strcmp (str, "1") == 0) return 1;
11419 str = getenv ("SKIP_TEST_MKFS");
11420 if (str && strcmp (str, "1") == 0) return 1;
11424 static int test_mkfs_0 (void)
11426 if (test_mkfs_0_skip ()) {
11427 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkfs_0");
11431 /* InitNone|InitEmpty for test_mkfs_0 */
11433 char device[] = "/dev/sda";
11434 device[5] = devchar;
11436 suppress_error = 0;
11437 r = guestfs_blockdev_setrw (g, device);
11443 suppress_error = 0;
11444 r = guestfs_umount_all (g);
11450 suppress_error = 0;
11451 r = guestfs_lvm_remove_all (g);
11455 /* TestOutput for mkfs (0) */
11456 char expected[] = "new file contents";
11458 char device[] = "/dev/sda";
11459 device[5] = devchar;
11460 char lines_0[] = ",";
11466 suppress_error = 0;
11467 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11472 char fstype[] = "ext2";
11473 char device[] = "/dev/sda1";
11474 device[5] = devchar;
11476 suppress_error = 0;
11477 r = guestfs_mkfs (g, fstype, device);
11482 char device[] = "/dev/sda1";
11483 device[5] = devchar;
11484 char mountpoint[] = "/";
11486 suppress_error = 0;
11487 r = guestfs_mount (g, device, mountpoint);
11492 char path[] = "/new";
11493 char content[] = "new file contents";
11495 suppress_error = 0;
11496 r = guestfs_write_file (g, path, content, 0);
11501 char path[] = "/new";
11503 suppress_error = 0;
11504 r = guestfs_cat (g, path);
11507 if (strcmp (r, expected) != 0) {
11508 fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
11516 static int test_lvcreate_0_skip (void)
11520 str = getenv ("SKIP_TEST_LVCREATE_0");
11521 if (str && strcmp (str, "1") == 0) return 1;
11522 str = getenv ("SKIP_TEST_LVCREATE");
11523 if (str && strcmp (str, "1") == 0) return 1;
11527 static int test_lvcreate_0 (void)
11529 if (test_lvcreate_0_skip ()) {
11530 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvcreate_0");
11534 /* InitNone|InitEmpty for test_lvcreate_0 */
11536 char device[] = "/dev/sda";
11537 device[5] = devchar;
11539 suppress_error = 0;
11540 r = guestfs_blockdev_setrw (g, device);
11546 suppress_error = 0;
11547 r = guestfs_umount_all (g);
11553 suppress_error = 0;
11554 r = guestfs_lvm_remove_all (g);
11558 /* TestOutputList for lvcreate (0) */
11560 char device[] = "/dev/sda";
11561 device[5] = devchar;
11562 char lines_0[] = ",10";
11563 char lines_1[] = ",20";
11564 char lines_2[] = ",";
11572 suppress_error = 0;
11573 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11578 char device[] = "/dev/sda1";
11579 device[5] = devchar;
11581 suppress_error = 0;
11582 r = guestfs_pvcreate (g, device);
11587 char device[] = "/dev/sda2";
11588 device[5] = devchar;
11590 suppress_error = 0;
11591 r = guestfs_pvcreate (g, device);
11596 char device[] = "/dev/sda3";
11597 device[5] = devchar;
11599 suppress_error = 0;
11600 r = guestfs_pvcreate (g, device);
11605 char volgroup[] = "VG1";
11606 char physvols_0[] = "/dev/sda1";
11607 physvols_0[5] = devchar;
11608 char physvols_1[] = "/dev/sda2";
11609 physvols_1[5] = devchar;
11610 char *physvols[] = {
11616 suppress_error = 0;
11617 r = guestfs_vgcreate (g, volgroup, physvols);
11622 char volgroup[] = "VG2";
11623 char physvols_0[] = "/dev/sda3";
11624 physvols_0[5] = devchar;
11625 char *physvols[] = {
11630 suppress_error = 0;
11631 r = guestfs_vgcreate (g, volgroup, physvols);
11636 char logvol[] = "LV1";
11637 char volgroup[] = "VG1";
11639 suppress_error = 0;
11640 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11645 char logvol[] = "LV2";
11646 char volgroup[] = "VG1";
11648 suppress_error = 0;
11649 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11654 char logvol[] = "LV3";
11655 char volgroup[] = "VG2";
11657 suppress_error = 0;
11658 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11663 char logvol[] = "LV4";
11664 char volgroup[] = "VG2";
11666 suppress_error = 0;
11667 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11672 char logvol[] = "LV5";
11673 char volgroup[] = "VG2";
11675 suppress_error = 0;
11676 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11683 suppress_error = 0;
11684 r = guestfs_lvs (g);
11688 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11693 char expected[] = "/dev/VG1/LV1";
11694 if (strcmp (r[0], expected) != 0) {
11695 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11700 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11705 char expected[] = "/dev/VG1/LV2";
11706 if (strcmp (r[1], expected) != 0) {
11707 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11712 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11717 char expected[] = "/dev/VG2/LV3";
11718 if (strcmp (r[2], expected) != 0) {
11719 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
11724 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11729 char expected[] = "/dev/VG2/LV4";
11730 if (strcmp (r[3], expected) != 0) {
11731 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
11736 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11741 char expected[] = "/dev/VG2/LV5";
11742 if (strcmp (r[4], expected) != 0) {
11743 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
11747 if (r[5] != NULL) {
11748 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
11752 for (i = 0; r[i] != NULL; ++i)
11759 static int test_vgcreate_0_skip (void)
11763 str = getenv ("SKIP_TEST_VGCREATE_0");
11764 if (str && strcmp (str, "1") == 0) return 1;
11765 str = getenv ("SKIP_TEST_VGCREATE");
11766 if (str && strcmp (str, "1") == 0) return 1;
11770 static int test_vgcreate_0 (void)
11772 if (test_vgcreate_0_skip ()) {
11773 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgcreate_0");
11777 /* InitNone|InitEmpty for test_vgcreate_0 */
11779 char device[] = "/dev/sda";
11780 device[5] = devchar;
11782 suppress_error = 0;
11783 r = guestfs_blockdev_setrw (g, device);
11789 suppress_error = 0;
11790 r = guestfs_umount_all (g);
11796 suppress_error = 0;
11797 r = guestfs_lvm_remove_all (g);
11801 /* TestOutputList for vgcreate (0) */
11803 char device[] = "/dev/sda";
11804 device[5] = devchar;
11805 char lines_0[] = ",10";
11806 char lines_1[] = ",20";
11807 char lines_2[] = ",";
11815 suppress_error = 0;
11816 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11821 char device[] = "/dev/sda1";
11822 device[5] = devchar;
11824 suppress_error = 0;
11825 r = guestfs_pvcreate (g, device);
11830 char device[] = "/dev/sda2";
11831 device[5] = devchar;
11833 suppress_error = 0;
11834 r = guestfs_pvcreate (g, device);
11839 char device[] = "/dev/sda3";
11840 device[5] = devchar;
11842 suppress_error = 0;
11843 r = guestfs_pvcreate (g, device);
11848 char volgroup[] = "VG1";
11849 char physvols_0[] = "/dev/sda1";
11850 physvols_0[5] = devchar;
11851 char physvols_1[] = "/dev/sda2";
11852 physvols_1[5] = devchar;
11853 char *physvols[] = {
11859 suppress_error = 0;
11860 r = guestfs_vgcreate (g, volgroup, physvols);
11865 char volgroup[] = "VG2";
11866 char physvols_0[] = "/dev/sda3";
11867 physvols_0[5] = devchar;
11868 char *physvols[] = {
11873 suppress_error = 0;
11874 r = guestfs_vgcreate (g, volgroup, physvols);
11881 suppress_error = 0;
11882 r = guestfs_vgs (g);
11886 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
11891 char expected[] = "VG1";
11892 if (strcmp (r[0], expected) != 0) {
11893 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11898 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
11903 char expected[] = "VG2";
11904 if (strcmp (r[1], expected) != 0) {
11905 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11909 if (r[2] != NULL) {
11910 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
11914 for (i = 0; r[i] != NULL; ++i)
11921 static int test_pvcreate_0_skip (void)
11925 str = getenv ("SKIP_TEST_PVCREATE_0");
11926 if (str && strcmp (str, "1") == 0) return 1;
11927 str = getenv ("SKIP_TEST_PVCREATE");
11928 if (str && strcmp (str, "1") == 0) return 1;
11932 static int test_pvcreate_0 (void)
11934 if (test_pvcreate_0_skip ()) {
11935 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvcreate_0");
11939 /* InitNone|InitEmpty for test_pvcreate_0 */
11941 char device[] = "/dev/sda";
11942 device[5] = devchar;
11944 suppress_error = 0;
11945 r = guestfs_blockdev_setrw (g, device);
11951 suppress_error = 0;
11952 r = guestfs_umount_all (g);
11958 suppress_error = 0;
11959 r = guestfs_lvm_remove_all (g);
11963 /* TestOutputList for pvcreate (0) */
11965 char device[] = "/dev/sda";
11966 device[5] = devchar;
11967 char lines_0[] = ",10";
11968 char lines_1[] = ",20";
11969 char lines_2[] = ",";
11977 suppress_error = 0;
11978 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11983 char device[] = "/dev/sda1";
11984 device[5] = devchar;
11986 suppress_error = 0;
11987 r = guestfs_pvcreate (g, device);
11992 char device[] = "/dev/sda2";
11993 device[5] = devchar;
11995 suppress_error = 0;
11996 r = guestfs_pvcreate (g, device);
12001 char device[] = "/dev/sda3";
12002 device[5] = devchar;
12004 suppress_error = 0;
12005 r = guestfs_pvcreate (g, device);
12012 suppress_error = 0;
12013 r = guestfs_pvs (g);
12017 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
12022 char expected[] = "/dev/sda1";
12023 expected[5] = devchar;
12024 if (strcmp (r[0], expected) != 0) {
12025 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
12030 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
12035 char expected[] = "/dev/sda2";
12036 expected[5] = devchar;
12037 if (strcmp (r[1], expected) != 0) {
12038 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
12043 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
12048 char expected[] = "/dev/sda3";
12049 expected[5] = devchar;
12050 if (strcmp (r[2], expected) != 0) {
12051 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
12055 if (r[3] != NULL) {
12056 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
12060 for (i = 0; r[i] != NULL; ++i)
12067 static int test_is_dir_0_skip (void)
12071 str = getenv ("SKIP_TEST_IS_DIR_0");
12072 if (str && strcmp (str, "1") == 0) return 1;
12073 str = getenv ("SKIP_TEST_IS_DIR");
12074 if (str && strcmp (str, "1") == 0) return 1;
12078 static int test_is_dir_0 (void)
12080 if (test_is_dir_0_skip ()) {
12081 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_0");
12085 /* InitBasicFS for test_is_dir_0: create ext2 on /dev/sda1 */
12087 char device[] = "/dev/sda";
12088 device[5] = devchar;
12090 suppress_error = 0;
12091 r = guestfs_blockdev_setrw (g, device);
12097 suppress_error = 0;
12098 r = guestfs_umount_all (g);
12104 suppress_error = 0;
12105 r = guestfs_lvm_remove_all (g);
12110 char device[] = "/dev/sda";
12111 device[5] = devchar;
12112 char lines_0[] = ",";
12118 suppress_error = 0;
12119 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12124 char fstype[] = "ext2";
12125 char device[] = "/dev/sda1";
12126 device[5] = devchar;
12128 suppress_error = 0;
12129 r = guestfs_mkfs (g, fstype, device);
12134 char device[] = "/dev/sda1";
12135 device[5] = devchar;
12136 char mountpoint[] = "/";
12138 suppress_error = 0;
12139 r = guestfs_mount (g, device, mountpoint);
12143 /* TestOutputFalse for is_dir (0) */
12145 char path[] = "/new";
12147 suppress_error = 0;
12148 r = guestfs_touch (g, path);
12153 char path[] = "/new";
12155 suppress_error = 0;
12156 r = guestfs_is_dir (g, path);
12160 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
12167 static int test_is_dir_1_skip (void)
12171 str = getenv ("SKIP_TEST_IS_DIR_1");
12172 if (str && strcmp (str, "1") == 0) return 1;
12173 str = getenv ("SKIP_TEST_IS_DIR");
12174 if (str && strcmp (str, "1") == 0) return 1;
12178 static int test_is_dir_1 (void)
12180 if (test_is_dir_1_skip ()) {
12181 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_1");
12185 /* InitBasicFS for test_is_dir_1: create ext2 on /dev/sda1 */
12187 char device[] = "/dev/sda";
12188 device[5] = devchar;
12190 suppress_error = 0;
12191 r = guestfs_blockdev_setrw (g, device);
12197 suppress_error = 0;
12198 r = guestfs_umount_all (g);
12204 suppress_error = 0;
12205 r = guestfs_lvm_remove_all (g);
12210 char device[] = "/dev/sda";
12211 device[5] = devchar;
12212 char lines_0[] = ",";
12218 suppress_error = 0;
12219 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12224 char fstype[] = "ext2";
12225 char device[] = "/dev/sda1";
12226 device[5] = devchar;
12228 suppress_error = 0;
12229 r = guestfs_mkfs (g, fstype, device);
12234 char device[] = "/dev/sda1";
12235 device[5] = devchar;
12236 char mountpoint[] = "/";
12238 suppress_error = 0;
12239 r = guestfs_mount (g, device, mountpoint);
12243 /* TestOutputTrue for is_dir (1) */
12245 char path[] = "/new";
12247 suppress_error = 0;
12248 r = guestfs_mkdir (g, path);
12253 char path[] = "/new";
12255 suppress_error = 0;
12256 r = guestfs_is_dir (g, path);
12260 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
12267 static int test_is_file_0_skip (void)
12271 str = getenv ("SKIP_TEST_IS_FILE_0");
12272 if (str && strcmp (str, "1") == 0) return 1;
12273 str = getenv ("SKIP_TEST_IS_FILE");
12274 if (str && strcmp (str, "1") == 0) return 1;
12278 static int test_is_file_0 (void)
12280 if (test_is_file_0_skip ()) {
12281 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_0");
12285 /* InitBasicFS for test_is_file_0: create ext2 on /dev/sda1 */
12287 char device[] = "/dev/sda";
12288 device[5] = devchar;
12290 suppress_error = 0;
12291 r = guestfs_blockdev_setrw (g, device);
12297 suppress_error = 0;
12298 r = guestfs_umount_all (g);
12304 suppress_error = 0;
12305 r = guestfs_lvm_remove_all (g);
12310 char device[] = "/dev/sda";
12311 device[5] = devchar;
12312 char lines_0[] = ",";
12318 suppress_error = 0;
12319 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12324 char fstype[] = "ext2";
12325 char device[] = "/dev/sda1";
12326 device[5] = devchar;
12328 suppress_error = 0;
12329 r = guestfs_mkfs (g, fstype, device);
12334 char device[] = "/dev/sda1";
12335 device[5] = devchar;
12336 char mountpoint[] = "/";
12338 suppress_error = 0;
12339 r = guestfs_mount (g, device, mountpoint);
12343 /* TestOutputTrue for is_file (0) */
12345 char path[] = "/new";
12347 suppress_error = 0;
12348 r = guestfs_touch (g, path);
12353 char path[] = "/new";
12355 suppress_error = 0;
12356 r = guestfs_is_file (g, path);
12360 fprintf (stderr, "test_is_file_0: expected true, got false\n");
12367 static int test_is_file_1_skip (void)
12371 str = getenv ("SKIP_TEST_IS_FILE_1");
12372 if (str && strcmp (str, "1") == 0) return 1;
12373 str = getenv ("SKIP_TEST_IS_FILE");
12374 if (str && strcmp (str, "1") == 0) return 1;
12378 static int test_is_file_1 (void)
12380 if (test_is_file_1_skip ()) {
12381 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_1");
12385 /* InitBasicFS for test_is_file_1: create ext2 on /dev/sda1 */
12387 char device[] = "/dev/sda";
12388 device[5] = devchar;
12390 suppress_error = 0;
12391 r = guestfs_blockdev_setrw (g, device);
12397 suppress_error = 0;
12398 r = guestfs_umount_all (g);
12404 suppress_error = 0;
12405 r = guestfs_lvm_remove_all (g);
12410 char device[] = "/dev/sda";
12411 device[5] = devchar;
12412 char lines_0[] = ",";
12418 suppress_error = 0;
12419 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12424 char fstype[] = "ext2";
12425 char device[] = "/dev/sda1";
12426 device[5] = devchar;
12428 suppress_error = 0;
12429 r = guestfs_mkfs (g, fstype, device);
12434 char device[] = "/dev/sda1";
12435 device[5] = devchar;
12436 char mountpoint[] = "/";
12438 suppress_error = 0;
12439 r = guestfs_mount (g, device, mountpoint);
12443 /* TestOutputFalse for is_file (1) */
12445 char path[] = "/new";
12447 suppress_error = 0;
12448 r = guestfs_mkdir (g, path);
12453 char path[] = "/new";
12455 suppress_error = 0;
12456 r = guestfs_is_file (g, path);
12460 fprintf (stderr, "test_is_file_1: expected false, got true\n");
12467 static int test_exists_0_skip (void)
12471 str = getenv ("SKIP_TEST_EXISTS_0");
12472 if (str && strcmp (str, "1") == 0) return 1;
12473 str = getenv ("SKIP_TEST_EXISTS");
12474 if (str && strcmp (str, "1") == 0) return 1;
12478 static int test_exists_0 (void)
12480 if (test_exists_0_skip ()) {
12481 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_0");
12485 /* InitBasicFS for test_exists_0: create ext2 on /dev/sda1 */
12487 char device[] = "/dev/sda";
12488 device[5] = devchar;
12490 suppress_error = 0;
12491 r = guestfs_blockdev_setrw (g, device);
12497 suppress_error = 0;
12498 r = guestfs_umount_all (g);
12504 suppress_error = 0;
12505 r = guestfs_lvm_remove_all (g);
12510 char device[] = "/dev/sda";
12511 device[5] = devchar;
12512 char lines_0[] = ",";
12518 suppress_error = 0;
12519 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12524 char fstype[] = "ext2";
12525 char device[] = "/dev/sda1";
12526 device[5] = devchar;
12528 suppress_error = 0;
12529 r = guestfs_mkfs (g, fstype, device);
12534 char device[] = "/dev/sda1";
12535 device[5] = devchar;
12536 char mountpoint[] = "/";
12538 suppress_error = 0;
12539 r = guestfs_mount (g, device, mountpoint);
12543 /* TestOutputTrue for exists (0) */
12545 char path[] = "/new";
12547 suppress_error = 0;
12548 r = guestfs_touch (g, path);
12553 char path[] = "/new";
12555 suppress_error = 0;
12556 r = guestfs_exists (g, path);
12560 fprintf (stderr, "test_exists_0: expected true, got false\n");
12567 static int test_exists_1_skip (void)
12571 str = getenv ("SKIP_TEST_EXISTS_1");
12572 if (str && strcmp (str, "1") == 0) return 1;
12573 str = getenv ("SKIP_TEST_EXISTS");
12574 if (str && strcmp (str, "1") == 0) return 1;
12578 static int test_exists_1 (void)
12580 if (test_exists_1_skip ()) {
12581 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_1");
12585 /* InitBasicFS for test_exists_1: create ext2 on /dev/sda1 */
12587 char device[] = "/dev/sda";
12588 device[5] = devchar;
12590 suppress_error = 0;
12591 r = guestfs_blockdev_setrw (g, device);
12597 suppress_error = 0;
12598 r = guestfs_umount_all (g);
12604 suppress_error = 0;
12605 r = guestfs_lvm_remove_all (g);
12610 char device[] = "/dev/sda";
12611 device[5] = devchar;
12612 char lines_0[] = ",";
12618 suppress_error = 0;
12619 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12624 char fstype[] = "ext2";
12625 char device[] = "/dev/sda1";
12626 device[5] = devchar;
12628 suppress_error = 0;
12629 r = guestfs_mkfs (g, fstype, device);
12634 char device[] = "/dev/sda1";
12635 device[5] = devchar;
12636 char mountpoint[] = "/";
12638 suppress_error = 0;
12639 r = guestfs_mount (g, device, mountpoint);
12643 /* TestOutputTrue for exists (1) */
12645 char path[] = "/new";
12647 suppress_error = 0;
12648 r = guestfs_mkdir (g, path);
12653 char path[] = "/new";
12655 suppress_error = 0;
12656 r = guestfs_exists (g, path);
12660 fprintf (stderr, "test_exists_1: expected true, got false\n");
12667 static int test_mkdir_p_0_skip (void)
12671 str = getenv ("SKIP_TEST_MKDIR_P_0");
12672 if (str && strcmp (str, "1") == 0) return 1;
12673 str = getenv ("SKIP_TEST_MKDIR_P");
12674 if (str && strcmp (str, "1") == 0) return 1;
12678 static int test_mkdir_p_0 (void)
12680 if (test_mkdir_p_0_skip ()) {
12681 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_0");
12685 /* InitBasicFS for test_mkdir_p_0: create ext2 on /dev/sda1 */
12687 char device[] = "/dev/sda";
12688 device[5] = devchar;
12690 suppress_error = 0;
12691 r = guestfs_blockdev_setrw (g, device);
12697 suppress_error = 0;
12698 r = guestfs_umount_all (g);
12704 suppress_error = 0;
12705 r = guestfs_lvm_remove_all (g);
12710 char device[] = "/dev/sda";
12711 device[5] = devchar;
12712 char lines_0[] = ",";
12718 suppress_error = 0;
12719 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12724 char fstype[] = "ext2";
12725 char device[] = "/dev/sda1";
12726 device[5] = devchar;
12728 suppress_error = 0;
12729 r = guestfs_mkfs (g, fstype, device);
12734 char device[] = "/dev/sda1";
12735 device[5] = devchar;
12736 char mountpoint[] = "/";
12738 suppress_error = 0;
12739 r = guestfs_mount (g, device, mountpoint);
12743 /* TestOutputTrue for mkdir_p (0) */
12745 char path[] = "/new/foo/bar";
12747 suppress_error = 0;
12748 r = guestfs_mkdir_p (g, path);
12753 char path[] = "/new/foo/bar";
12755 suppress_error = 0;
12756 r = guestfs_is_dir (g, path);
12760 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
12767 static int test_mkdir_p_1_skip (void)
12771 str = getenv ("SKIP_TEST_MKDIR_P_1");
12772 if (str && strcmp (str, "1") == 0) return 1;
12773 str = getenv ("SKIP_TEST_MKDIR_P");
12774 if (str && strcmp (str, "1") == 0) return 1;
12778 static int test_mkdir_p_1 (void)
12780 if (test_mkdir_p_1_skip ()) {
12781 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_1");
12785 /* InitBasicFS for test_mkdir_p_1: create ext2 on /dev/sda1 */
12787 char device[] = "/dev/sda";
12788 device[5] = devchar;
12790 suppress_error = 0;
12791 r = guestfs_blockdev_setrw (g, device);
12797 suppress_error = 0;
12798 r = guestfs_umount_all (g);
12804 suppress_error = 0;
12805 r = guestfs_lvm_remove_all (g);
12810 char device[] = "/dev/sda";
12811 device[5] = devchar;
12812 char lines_0[] = ",";
12818 suppress_error = 0;
12819 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12824 char fstype[] = "ext2";
12825 char device[] = "/dev/sda1";
12826 device[5] = devchar;
12828 suppress_error = 0;
12829 r = guestfs_mkfs (g, fstype, device);
12834 char device[] = "/dev/sda1";
12835 device[5] = devchar;
12836 char mountpoint[] = "/";
12838 suppress_error = 0;
12839 r = guestfs_mount (g, device, mountpoint);
12843 /* TestOutputTrue for mkdir_p (1) */
12845 char path[] = "/new/foo/bar";
12847 suppress_error = 0;
12848 r = guestfs_mkdir_p (g, path);
12853 char path[] = "/new/foo";
12855 suppress_error = 0;
12856 r = guestfs_is_dir (g, path);
12860 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
12867 static int test_mkdir_p_2_skip (void)
12871 str = getenv ("SKIP_TEST_MKDIR_P_2");
12872 if (str && strcmp (str, "1") == 0) return 1;
12873 str = getenv ("SKIP_TEST_MKDIR_P");
12874 if (str && strcmp (str, "1") == 0) return 1;
12878 static int test_mkdir_p_2 (void)
12880 if (test_mkdir_p_2_skip ()) {
12881 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_2");
12885 /* InitBasicFS for test_mkdir_p_2: create ext2 on /dev/sda1 */
12887 char device[] = "/dev/sda";
12888 device[5] = devchar;
12890 suppress_error = 0;
12891 r = guestfs_blockdev_setrw (g, device);
12897 suppress_error = 0;
12898 r = guestfs_umount_all (g);
12904 suppress_error = 0;
12905 r = guestfs_lvm_remove_all (g);
12910 char device[] = "/dev/sda";
12911 device[5] = devchar;
12912 char lines_0[] = ",";
12918 suppress_error = 0;
12919 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12924 char fstype[] = "ext2";
12925 char device[] = "/dev/sda1";
12926 device[5] = devchar;
12928 suppress_error = 0;
12929 r = guestfs_mkfs (g, fstype, device);
12934 char device[] = "/dev/sda1";
12935 device[5] = devchar;
12936 char mountpoint[] = "/";
12938 suppress_error = 0;
12939 r = guestfs_mount (g, device, mountpoint);
12943 /* TestOutputTrue for mkdir_p (2) */
12945 char path[] = "/new/foo/bar";
12947 suppress_error = 0;
12948 r = guestfs_mkdir_p (g, path);
12953 char path[] = "/new";
12955 suppress_error = 0;
12956 r = guestfs_is_dir (g, path);
12960 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
12967 static int test_mkdir_p_3_skip (void)
12971 str = getenv ("SKIP_TEST_MKDIR_P_3");
12972 if (str && strcmp (str, "1") == 0) return 1;
12973 str = getenv ("SKIP_TEST_MKDIR_P");
12974 if (str && strcmp (str, "1") == 0) return 1;
12978 static int test_mkdir_p_3 (void)
12980 if (test_mkdir_p_3_skip ()) {
12981 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_3");
12985 /* InitBasicFS for test_mkdir_p_3: create ext2 on /dev/sda1 */
12987 char device[] = "/dev/sda";
12988 device[5] = devchar;
12990 suppress_error = 0;
12991 r = guestfs_blockdev_setrw (g, device);
12997 suppress_error = 0;
12998 r = guestfs_umount_all (g);
13004 suppress_error = 0;
13005 r = guestfs_lvm_remove_all (g);
13010 char device[] = "/dev/sda";
13011 device[5] = devchar;
13012 char lines_0[] = ",";
13018 suppress_error = 0;
13019 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13024 char fstype[] = "ext2";
13025 char device[] = "/dev/sda1";
13026 device[5] = devchar;
13028 suppress_error = 0;
13029 r = guestfs_mkfs (g, fstype, device);
13034 char device[] = "/dev/sda1";
13035 device[5] = devchar;
13036 char mountpoint[] = "/";
13038 suppress_error = 0;
13039 r = guestfs_mount (g, device, mountpoint);
13043 /* TestRun for mkdir_p (3) */
13045 char path[] = "/new";
13047 suppress_error = 0;
13048 r = guestfs_mkdir (g, path);
13053 char path[] = "/new";
13055 suppress_error = 0;
13056 r = guestfs_mkdir_p (g, path);
13063 static int test_mkdir_p_4_skip (void)
13067 str = getenv ("SKIP_TEST_MKDIR_P_4");
13068 if (str && strcmp (str, "1") == 0) return 1;
13069 str = getenv ("SKIP_TEST_MKDIR_P");
13070 if (str && strcmp (str, "1") == 0) return 1;
13074 static int test_mkdir_p_4 (void)
13076 if (test_mkdir_p_4_skip ()) {
13077 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_4");
13081 /* InitBasicFS for test_mkdir_p_4: create ext2 on /dev/sda1 */
13083 char device[] = "/dev/sda";
13084 device[5] = devchar;
13086 suppress_error = 0;
13087 r = guestfs_blockdev_setrw (g, device);
13093 suppress_error = 0;
13094 r = guestfs_umount_all (g);
13100 suppress_error = 0;
13101 r = guestfs_lvm_remove_all (g);
13106 char device[] = "/dev/sda";
13107 device[5] = devchar;
13108 char lines_0[] = ",";
13114 suppress_error = 0;
13115 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13120 char fstype[] = "ext2";
13121 char device[] = "/dev/sda1";
13122 device[5] = devchar;
13124 suppress_error = 0;
13125 r = guestfs_mkfs (g, fstype, device);
13130 char device[] = "/dev/sda1";
13131 device[5] = devchar;
13132 char mountpoint[] = "/";
13134 suppress_error = 0;
13135 r = guestfs_mount (g, device, mountpoint);
13139 /* TestLastFail for mkdir_p (4) */
13141 char path[] = "/new";
13143 suppress_error = 0;
13144 r = guestfs_touch (g, path);
13149 char path[] = "/new";
13151 suppress_error = 1;
13152 r = guestfs_mkdir_p (g, path);
13159 static int test_mkdir_0_skip (void)
13163 str = getenv ("SKIP_TEST_MKDIR_0");
13164 if (str && strcmp (str, "1") == 0) return 1;
13165 str = getenv ("SKIP_TEST_MKDIR");
13166 if (str && strcmp (str, "1") == 0) return 1;
13170 static int test_mkdir_0 (void)
13172 if (test_mkdir_0_skip ()) {
13173 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_0");
13177 /* InitBasicFS for test_mkdir_0: create ext2 on /dev/sda1 */
13179 char device[] = "/dev/sda";
13180 device[5] = devchar;
13182 suppress_error = 0;
13183 r = guestfs_blockdev_setrw (g, device);
13189 suppress_error = 0;
13190 r = guestfs_umount_all (g);
13196 suppress_error = 0;
13197 r = guestfs_lvm_remove_all (g);
13202 char device[] = "/dev/sda";
13203 device[5] = devchar;
13204 char lines_0[] = ",";
13210 suppress_error = 0;
13211 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13216 char fstype[] = "ext2";
13217 char device[] = "/dev/sda1";
13218 device[5] = devchar;
13220 suppress_error = 0;
13221 r = guestfs_mkfs (g, fstype, device);
13226 char device[] = "/dev/sda1";
13227 device[5] = devchar;
13228 char mountpoint[] = "/";
13230 suppress_error = 0;
13231 r = guestfs_mount (g, device, mountpoint);
13235 /* TestOutputTrue for mkdir (0) */
13237 char path[] = "/new";
13239 suppress_error = 0;
13240 r = guestfs_mkdir (g, path);
13245 char path[] = "/new";
13247 suppress_error = 0;
13248 r = guestfs_is_dir (g, path);
13252 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
13259 static int test_mkdir_1_skip (void)
13263 str = getenv ("SKIP_TEST_MKDIR_1");
13264 if (str && strcmp (str, "1") == 0) return 1;
13265 str = getenv ("SKIP_TEST_MKDIR");
13266 if (str && strcmp (str, "1") == 0) return 1;
13270 static int test_mkdir_1 (void)
13272 if (test_mkdir_1_skip ()) {
13273 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_1");
13277 /* InitBasicFS for test_mkdir_1: create ext2 on /dev/sda1 */
13279 char device[] = "/dev/sda";
13280 device[5] = devchar;
13282 suppress_error = 0;
13283 r = guestfs_blockdev_setrw (g, device);
13289 suppress_error = 0;
13290 r = guestfs_umount_all (g);
13296 suppress_error = 0;
13297 r = guestfs_lvm_remove_all (g);
13302 char device[] = "/dev/sda";
13303 device[5] = devchar;
13304 char lines_0[] = ",";
13310 suppress_error = 0;
13311 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13316 char fstype[] = "ext2";
13317 char device[] = "/dev/sda1";
13318 device[5] = devchar;
13320 suppress_error = 0;
13321 r = guestfs_mkfs (g, fstype, device);
13326 char device[] = "/dev/sda1";
13327 device[5] = devchar;
13328 char mountpoint[] = "/";
13330 suppress_error = 0;
13331 r = guestfs_mount (g, device, mountpoint);
13335 /* TestLastFail for mkdir (1) */
13337 char path[] = "/new/foo/bar";
13339 suppress_error = 1;
13340 r = guestfs_mkdir (g, path);
13347 static int test_rm_rf_0_skip (void)
13351 str = getenv ("SKIP_TEST_RM_RF_0");
13352 if (str && strcmp (str, "1") == 0) return 1;
13353 str = getenv ("SKIP_TEST_RM_RF");
13354 if (str && strcmp (str, "1") == 0) return 1;
13358 static int test_rm_rf_0 (void)
13360 if (test_rm_rf_0_skip ()) {
13361 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_rf_0");
13365 /* InitBasicFS for test_rm_rf_0: create ext2 on /dev/sda1 */
13367 char device[] = "/dev/sda";
13368 device[5] = devchar;
13370 suppress_error = 0;
13371 r = guestfs_blockdev_setrw (g, device);
13377 suppress_error = 0;
13378 r = guestfs_umount_all (g);
13384 suppress_error = 0;
13385 r = guestfs_lvm_remove_all (g);
13390 char device[] = "/dev/sda";
13391 device[5] = devchar;
13392 char lines_0[] = ",";
13398 suppress_error = 0;
13399 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13404 char fstype[] = "ext2";
13405 char device[] = "/dev/sda1";
13406 device[5] = devchar;
13408 suppress_error = 0;
13409 r = guestfs_mkfs (g, fstype, device);
13414 char device[] = "/dev/sda1";
13415 device[5] = devchar;
13416 char mountpoint[] = "/";
13418 suppress_error = 0;
13419 r = guestfs_mount (g, device, mountpoint);
13423 /* TestOutputFalse for rm_rf (0) */
13425 char path[] = "/new";
13427 suppress_error = 0;
13428 r = guestfs_mkdir (g, path);
13433 char path[] = "/new/foo";
13435 suppress_error = 0;
13436 r = guestfs_mkdir (g, path);
13441 char path[] = "/new/foo/bar";
13443 suppress_error = 0;
13444 r = guestfs_touch (g, path);
13449 char path[] = "/new";
13451 suppress_error = 0;
13452 r = guestfs_rm_rf (g, path);
13457 char path[] = "/new";
13459 suppress_error = 0;
13460 r = guestfs_exists (g, path);
13464 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
13471 static int test_rmdir_0_skip (void)
13475 str = getenv ("SKIP_TEST_RMDIR_0");
13476 if (str && strcmp (str, "1") == 0) return 1;
13477 str = getenv ("SKIP_TEST_RMDIR");
13478 if (str && strcmp (str, "1") == 0) return 1;
13482 static int test_rmdir_0 (void)
13484 if (test_rmdir_0_skip ()) {
13485 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_0");
13489 /* InitBasicFS for test_rmdir_0: create ext2 on /dev/sda1 */
13491 char device[] = "/dev/sda";
13492 device[5] = devchar;
13494 suppress_error = 0;
13495 r = guestfs_blockdev_setrw (g, device);
13501 suppress_error = 0;
13502 r = guestfs_umount_all (g);
13508 suppress_error = 0;
13509 r = guestfs_lvm_remove_all (g);
13514 char device[] = "/dev/sda";
13515 device[5] = devchar;
13516 char lines_0[] = ",";
13522 suppress_error = 0;
13523 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13528 char fstype[] = "ext2";
13529 char device[] = "/dev/sda1";
13530 device[5] = devchar;
13532 suppress_error = 0;
13533 r = guestfs_mkfs (g, fstype, device);
13538 char device[] = "/dev/sda1";
13539 device[5] = devchar;
13540 char mountpoint[] = "/";
13542 suppress_error = 0;
13543 r = guestfs_mount (g, device, mountpoint);
13547 /* TestRun for rmdir (0) */
13549 char path[] = "/new";
13551 suppress_error = 0;
13552 r = guestfs_mkdir (g, path);
13557 char path[] = "/new";
13559 suppress_error = 0;
13560 r = guestfs_rmdir (g, path);
13567 static int test_rmdir_1_skip (void)
13571 str = getenv ("SKIP_TEST_RMDIR_1");
13572 if (str && strcmp (str, "1") == 0) return 1;
13573 str = getenv ("SKIP_TEST_RMDIR");
13574 if (str && strcmp (str, "1") == 0) return 1;
13578 static int test_rmdir_1 (void)
13580 if (test_rmdir_1_skip ()) {
13581 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_1");
13585 /* InitBasicFS for test_rmdir_1: create ext2 on /dev/sda1 */
13587 char device[] = "/dev/sda";
13588 device[5] = devchar;
13590 suppress_error = 0;
13591 r = guestfs_blockdev_setrw (g, device);
13597 suppress_error = 0;
13598 r = guestfs_umount_all (g);
13604 suppress_error = 0;
13605 r = guestfs_lvm_remove_all (g);
13610 char device[] = "/dev/sda";
13611 device[5] = devchar;
13612 char lines_0[] = ",";
13618 suppress_error = 0;
13619 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13624 char fstype[] = "ext2";
13625 char device[] = "/dev/sda1";
13626 device[5] = devchar;
13628 suppress_error = 0;
13629 r = guestfs_mkfs (g, fstype, device);
13634 char device[] = "/dev/sda1";
13635 device[5] = devchar;
13636 char mountpoint[] = "/";
13638 suppress_error = 0;
13639 r = guestfs_mount (g, device, mountpoint);
13643 /* TestLastFail for rmdir (1) */
13645 char path[] = "/new";
13647 suppress_error = 1;
13648 r = guestfs_rmdir (g, path);
13655 static int test_rmdir_2_skip (void)
13659 str = getenv ("SKIP_TEST_RMDIR_2");
13660 if (str && strcmp (str, "1") == 0) return 1;
13661 str = getenv ("SKIP_TEST_RMDIR");
13662 if (str && strcmp (str, "1") == 0) return 1;
13666 static int test_rmdir_2 (void)
13668 if (test_rmdir_2_skip ()) {
13669 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_2");
13673 /* InitBasicFS for test_rmdir_2: create ext2 on /dev/sda1 */
13675 char device[] = "/dev/sda";
13676 device[5] = devchar;
13678 suppress_error = 0;
13679 r = guestfs_blockdev_setrw (g, device);
13685 suppress_error = 0;
13686 r = guestfs_umount_all (g);
13692 suppress_error = 0;
13693 r = guestfs_lvm_remove_all (g);
13698 char device[] = "/dev/sda";
13699 device[5] = devchar;
13700 char lines_0[] = ",";
13706 suppress_error = 0;
13707 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13712 char fstype[] = "ext2";
13713 char device[] = "/dev/sda1";
13714 device[5] = devchar;
13716 suppress_error = 0;
13717 r = guestfs_mkfs (g, fstype, device);
13722 char device[] = "/dev/sda1";
13723 device[5] = devchar;
13724 char mountpoint[] = "/";
13726 suppress_error = 0;
13727 r = guestfs_mount (g, device, mountpoint);
13731 /* TestLastFail for rmdir (2) */
13733 char path[] = "/new";
13735 suppress_error = 0;
13736 r = guestfs_touch (g, path);
13741 char path[] = "/new";
13743 suppress_error = 1;
13744 r = guestfs_rmdir (g, path);
13751 static int test_rm_0_skip (void)
13755 str = getenv ("SKIP_TEST_RM_0");
13756 if (str && strcmp (str, "1") == 0) return 1;
13757 str = getenv ("SKIP_TEST_RM");
13758 if (str && strcmp (str, "1") == 0) return 1;
13762 static int test_rm_0 (void)
13764 if (test_rm_0_skip ()) {
13765 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_0");
13769 /* InitBasicFS for test_rm_0: create ext2 on /dev/sda1 */
13771 char device[] = "/dev/sda";
13772 device[5] = devchar;
13774 suppress_error = 0;
13775 r = guestfs_blockdev_setrw (g, device);
13781 suppress_error = 0;
13782 r = guestfs_umount_all (g);
13788 suppress_error = 0;
13789 r = guestfs_lvm_remove_all (g);
13794 char device[] = "/dev/sda";
13795 device[5] = devchar;
13796 char lines_0[] = ",";
13802 suppress_error = 0;
13803 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13808 char fstype[] = "ext2";
13809 char device[] = "/dev/sda1";
13810 device[5] = devchar;
13812 suppress_error = 0;
13813 r = guestfs_mkfs (g, fstype, device);
13818 char device[] = "/dev/sda1";
13819 device[5] = devchar;
13820 char mountpoint[] = "/";
13822 suppress_error = 0;
13823 r = guestfs_mount (g, device, mountpoint);
13827 /* TestRun for rm (0) */
13829 char path[] = "/new";
13831 suppress_error = 0;
13832 r = guestfs_touch (g, path);
13837 char path[] = "/new";
13839 suppress_error = 0;
13840 r = guestfs_rm (g, path);
13847 static int test_rm_1_skip (void)
13851 str = getenv ("SKIP_TEST_RM_1");
13852 if (str && strcmp (str, "1") == 0) return 1;
13853 str = getenv ("SKIP_TEST_RM");
13854 if (str && strcmp (str, "1") == 0) return 1;
13858 static int test_rm_1 (void)
13860 if (test_rm_1_skip ()) {
13861 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_1");
13865 /* InitBasicFS for test_rm_1: create ext2 on /dev/sda1 */
13867 char device[] = "/dev/sda";
13868 device[5] = devchar;
13870 suppress_error = 0;
13871 r = guestfs_blockdev_setrw (g, device);
13877 suppress_error = 0;
13878 r = guestfs_umount_all (g);
13884 suppress_error = 0;
13885 r = guestfs_lvm_remove_all (g);
13890 char device[] = "/dev/sda";
13891 device[5] = devchar;
13892 char lines_0[] = ",";
13898 suppress_error = 0;
13899 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13904 char fstype[] = "ext2";
13905 char device[] = "/dev/sda1";
13906 device[5] = devchar;
13908 suppress_error = 0;
13909 r = guestfs_mkfs (g, fstype, device);
13914 char device[] = "/dev/sda1";
13915 device[5] = devchar;
13916 char mountpoint[] = "/";
13918 suppress_error = 0;
13919 r = guestfs_mount (g, device, mountpoint);
13923 /* TestLastFail for rm (1) */
13925 char path[] = "/new";
13927 suppress_error = 1;
13928 r = guestfs_rm (g, path);
13935 static int test_rm_2_skip (void)
13939 str = getenv ("SKIP_TEST_RM_2");
13940 if (str && strcmp (str, "1") == 0) return 1;
13941 str = getenv ("SKIP_TEST_RM");
13942 if (str && strcmp (str, "1") == 0) return 1;
13946 static int test_rm_2 (void)
13948 if (test_rm_2_skip ()) {
13949 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_2");
13953 /* InitBasicFS for test_rm_2: create ext2 on /dev/sda1 */
13955 char device[] = "/dev/sda";
13956 device[5] = devchar;
13958 suppress_error = 0;
13959 r = guestfs_blockdev_setrw (g, device);
13965 suppress_error = 0;
13966 r = guestfs_umount_all (g);
13972 suppress_error = 0;
13973 r = guestfs_lvm_remove_all (g);
13978 char device[] = "/dev/sda";
13979 device[5] = devchar;
13980 char lines_0[] = ",";
13986 suppress_error = 0;
13987 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13992 char fstype[] = "ext2";
13993 char device[] = "/dev/sda1";
13994 device[5] = devchar;
13996 suppress_error = 0;
13997 r = guestfs_mkfs (g, fstype, device);
14002 char device[] = "/dev/sda1";
14003 device[5] = devchar;
14004 char mountpoint[] = "/";
14006 suppress_error = 0;
14007 r = guestfs_mount (g, device, mountpoint);
14011 /* TestLastFail for rm (2) */
14013 char path[] = "/new";
14015 suppress_error = 0;
14016 r = guestfs_mkdir (g, path);
14021 char path[] = "/new";
14023 suppress_error = 1;
14024 r = guestfs_rm (g, path);
14031 static int test_read_lines_0_skip (void)
14035 str = getenv ("SKIP_TEST_READ_LINES_0");
14036 if (str && strcmp (str, "1") == 0) return 1;
14037 str = getenv ("SKIP_TEST_READ_LINES");
14038 if (str && strcmp (str, "1") == 0) return 1;
14042 static int test_read_lines_0 (void)
14044 if (test_read_lines_0_skip ()) {
14045 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_0");
14049 /* InitBasicFS for test_read_lines_0: create ext2 on /dev/sda1 */
14051 char device[] = "/dev/sda";
14052 device[5] = devchar;
14054 suppress_error = 0;
14055 r = guestfs_blockdev_setrw (g, device);
14061 suppress_error = 0;
14062 r = guestfs_umount_all (g);
14068 suppress_error = 0;
14069 r = guestfs_lvm_remove_all (g);
14074 char device[] = "/dev/sda";
14075 device[5] = devchar;
14076 char lines_0[] = ",";
14082 suppress_error = 0;
14083 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14088 char fstype[] = "ext2";
14089 char device[] = "/dev/sda1";
14090 device[5] = devchar;
14092 suppress_error = 0;
14093 r = guestfs_mkfs (g, fstype, device);
14098 char device[] = "/dev/sda1";
14099 device[5] = devchar;
14100 char mountpoint[] = "/";
14102 suppress_error = 0;
14103 r = guestfs_mount (g, device, mountpoint);
14107 /* TestOutputList for read_lines (0) */
14109 char path[] = "/new";
14110 char content[] = "line1\r\nline2\nline3";
14112 suppress_error = 0;
14113 r = guestfs_write_file (g, path, content, 0);
14118 char path[] = "/new";
14121 suppress_error = 0;
14122 r = guestfs_read_lines (g, path);
14126 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14131 char expected[] = "line1";
14132 if (strcmp (r[0], expected) != 0) {
14133 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14138 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14143 char expected[] = "line2";
14144 if (strcmp (r[1], expected) != 0) {
14145 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14150 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14155 char expected[] = "line3";
14156 if (strcmp (r[2], expected) != 0) {
14157 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14161 if (r[3] != NULL) {
14162 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
14166 for (i = 0; r[i] != NULL; ++i)
14173 static int test_read_lines_1_skip (void)
14177 str = getenv ("SKIP_TEST_READ_LINES_1");
14178 if (str && strcmp (str, "1") == 0) return 1;
14179 str = getenv ("SKIP_TEST_READ_LINES");
14180 if (str && strcmp (str, "1") == 0) return 1;
14184 static int test_read_lines_1 (void)
14186 if (test_read_lines_1_skip ()) {
14187 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_1");
14191 /* InitBasicFS for test_read_lines_1: create ext2 on /dev/sda1 */
14193 char device[] = "/dev/sda";
14194 device[5] = devchar;
14196 suppress_error = 0;
14197 r = guestfs_blockdev_setrw (g, device);
14203 suppress_error = 0;
14204 r = guestfs_umount_all (g);
14210 suppress_error = 0;
14211 r = guestfs_lvm_remove_all (g);
14216 char device[] = "/dev/sda";
14217 device[5] = devchar;
14218 char lines_0[] = ",";
14224 suppress_error = 0;
14225 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14230 char fstype[] = "ext2";
14231 char device[] = "/dev/sda1";
14232 device[5] = devchar;
14234 suppress_error = 0;
14235 r = guestfs_mkfs (g, fstype, device);
14240 char device[] = "/dev/sda1";
14241 device[5] = devchar;
14242 char mountpoint[] = "/";
14244 suppress_error = 0;
14245 r = guestfs_mount (g, device, mountpoint);
14249 /* TestOutputList for read_lines (1) */
14251 char path[] = "/new";
14252 char content[] = "";
14254 suppress_error = 0;
14255 r = guestfs_write_file (g, path, content, 0);
14260 char path[] = "/new";
14263 suppress_error = 0;
14264 r = guestfs_read_lines (g, path);
14267 if (r[0] != NULL) {
14268 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
14272 for (i = 0; r[i] != NULL; ++i)
14279 static int test_lvs_0_skip (void)
14283 str = getenv ("SKIP_TEST_LVS_0");
14284 if (str && strcmp (str, "1") == 0) return 1;
14285 str = getenv ("SKIP_TEST_LVS");
14286 if (str && strcmp (str, "1") == 0) return 1;
14290 static int test_lvs_0 (void)
14292 if (test_lvs_0_skip ()) {
14293 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_0");
14297 /* InitBasicFSonLVM for test_lvs_0: create ext2 on /dev/VG/LV */
14299 char device[] = "/dev/sda";
14300 device[5] = devchar;
14302 suppress_error = 0;
14303 r = guestfs_blockdev_setrw (g, device);
14309 suppress_error = 0;
14310 r = guestfs_umount_all (g);
14316 suppress_error = 0;
14317 r = guestfs_lvm_remove_all (g);
14322 char device[] = "/dev/sda";
14323 device[5] = devchar;
14324 char lines_0[] = ",";
14330 suppress_error = 0;
14331 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14336 char device[] = "/dev/sda1";
14337 device[5] = devchar;
14339 suppress_error = 0;
14340 r = guestfs_pvcreate (g, device);
14345 char volgroup[] = "VG";
14346 char physvols_0[] = "/dev/sda1";
14347 physvols_0[5] = devchar;
14348 char *physvols[] = {
14353 suppress_error = 0;
14354 r = guestfs_vgcreate (g, volgroup, physvols);
14359 char logvol[] = "LV";
14360 char volgroup[] = "VG";
14362 suppress_error = 0;
14363 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14368 char fstype[] = "ext2";
14369 char device[] = "/dev/VG/LV";
14371 suppress_error = 0;
14372 r = guestfs_mkfs (g, fstype, device);
14377 char device[] = "/dev/VG/LV";
14378 char mountpoint[] = "/";
14380 suppress_error = 0;
14381 r = guestfs_mount (g, device, mountpoint);
14385 /* TestOutputList for lvs (0) */
14389 suppress_error = 0;
14390 r = guestfs_lvs (g);
14394 fprintf (stderr, "test_lvs_0: short list returned from command\n");
14399 char expected[] = "/dev/VG/LV";
14400 if (strcmp (r[0], expected) != 0) {
14401 fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14405 if (r[1] != NULL) {
14406 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
14410 for (i = 0; r[i] != NULL; ++i)
14417 static int test_lvs_1_skip (void)
14421 str = getenv ("SKIP_TEST_LVS_1");
14422 if (str && strcmp (str, "1") == 0) return 1;
14423 str = getenv ("SKIP_TEST_LVS");
14424 if (str && strcmp (str, "1") == 0) return 1;
14428 static int test_lvs_1 (void)
14430 if (test_lvs_1_skip ()) {
14431 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_1");
14435 /* InitNone|InitEmpty for test_lvs_1 */
14437 char device[] = "/dev/sda";
14438 device[5] = devchar;
14440 suppress_error = 0;
14441 r = guestfs_blockdev_setrw (g, device);
14447 suppress_error = 0;
14448 r = guestfs_umount_all (g);
14454 suppress_error = 0;
14455 r = guestfs_lvm_remove_all (g);
14459 /* TestOutputList for lvs (1) */
14461 char device[] = "/dev/sda";
14462 device[5] = devchar;
14463 char lines_0[] = ",10";
14464 char lines_1[] = ",20";
14465 char lines_2[] = ",";
14473 suppress_error = 0;
14474 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14479 char device[] = "/dev/sda1";
14480 device[5] = devchar;
14482 suppress_error = 0;
14483 r = guestfs_pvcreate (g, device);
14488 char device[] = "/dev/sda2";
14489 device[5] = devchar;
14491 suppress_error = 0;
14492 r = guestfs_pvcreate (g, device);
14497 char device[] = "/dev/sda3";
14498 device[5] = devchar;
14500 suppress_error = 0;
14501 r = guestfs_pvcreate (g, device);
14506 char volgroup[] = "VG1";
14507 char physvols_0[] = "/dev/sda1";
14508 physvols_0[5] = devchar;
14509 char physvols_1[] = "/dev/sda2";
14510 physvols_1[5] = devchar;
14511 char *physvols[] = {
14517 suppress_error = 0;
14518 r = guestfs_vgcreate (g, volgroup, physvols);
14523 char volgroup[] = "VG2";
14524 char physvols_0[] = "/dev/sda3";
14525 physvols_0[5] = devchar;
14526 char *physvols[] = {
14531 suppress_error = 0;
14532 r = guestfs_vgcreate (g, volgroup, physvols);
14537 char logvol[] = "LV1";
14538 char volgroup[] = "VG1";
14540 suppress_error = 0;
14541 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14546 char logvol[] = "LV2";
14547 char volgroup[] = "VG1";
14549 suppress_error = 0;
14550 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14555 char logvol[] = "LV3";
14556 char volgroup[] = "VG2";
14558 suppress_error = 0;
14559 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14566 suppress_error = 0;
14567 r = guestfs_lvs (g);
14571 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14576 char expected[] = "/dev/VG1/LV1";
14577 if (strcmp (r[0], expected) != 0) {
14578 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14583 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14588 char expected[] = "/dev/VG1/LV2";
14589 if (strcmp (r[1], expected) != 0) {
14590 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14595 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14600 char expected[] = "/dev/VG2/LV3";
14601 if (strcmp (r[2], expected) != 0) {
14602 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14606 if (r[3] != NULL) {
14607 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
14611 for (i = 0; r[i] != NULL; ++i)
14618 static int test_vgs_0_skip (void)
14622 str = getenv ("SKIP_TEST_VGS_0");
14623 if (str && strcmp (str, "1") == 0) return 1;
14624 str = getenv ("SKIP_TEST_VGS");
14625 if (str && strcmp (str, "1") == 0) return 1;
14629 static int test_vgs_0 (void)
14631 if (test_vgs_0_skip ()) {
14632 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_0");
14636 /* InitBasicFSonLVM for test_vgs_0: create ext2 on /dev/VG/LV */
14638 char device[] = "/dev/sda";
14639 device[5] = devchar;
14641 suppress_error = 0;
14642 r = guestfs_blockdev_setrw (g, device);
14648 suppress_error = 0;
14649 r = guestfs_umount_all (g);
14655 suppress_error = 0;
14656 r = guestfs_lvm_remove_all (g);
14661 char device[] = "/dev/sda";
14662 device[5] = devchar;
14663 char lines_0[] = ",";
14669 suppress_error = 0;
14670 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14675 char device[] = "/dev/sda1";
14676 device[5] = devchar;
14678 suppress_error = 0;
14679 r = guestfs_pvcreate (g, device);
14684 char volgroup[] = "VG";
14685 char physvols_0[] = "/dev/sda1";
14686 physvols_0[5] = devchar;
14687 char *physvols[] = {
14692 suppress_error = 0;
14693 r = guestfs_vgcreate (g, volgroup, physvols);
14698 char logvol[] = "LV";
14699 char volgroup[] = "VG";
14701 suppress_error = 0;
14702 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14707 char fstype[] = "ext2";
14708 char device[] = "/dev/VG/LV";
14710 suppress_error = 0;
14711 r = guestfs_mkfs (g, fstype, device);
14716 char device[] = "/dev/VG/LV";
14717 char mountpoint[] = "/";
14719 suppress_error = 0;
14720 r = guestfs_mount (g, device, mountpoint);
14724 /* TestOutputList for vgs (0) */
14728 suppress_error = 0;
14729 r = guestfs_vgs (g);
14733 fprintf (stderr, "test_vgs_0: short list returned from command\n");
14738 char expected[] = "VG";
14739 if (strcmp (r[0], expected) != 0) {
14740 fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14744 if (r[1] != NULL) {
14745 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
14749 for (i = 0; r[i] != NULL; ++i)
14756 static int test_vgs_1_skip (void)
14760 str = getenv ("SKIP_TEST_VGS_1");
14761 if (str && strcmp (str, "1") == 0) return 1;
14762 str = getenv ("SKIP_TEST_VGS");
14763 if (str && strcmp (str, "1") == 0) return 1;
14767 static int test_vgs_1 (void)
14769 if (test_vgs_1_skip ()) {
14770 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_1");
14774 /* InitNone|InitEmpty for test_vgs_1 */
14776 char device[] = "/dev/sda";
14777 device[5] = devchar;
14779 suppress_error = 0;
14780 r = guestfs_blockdev_setrw (g, device);
14786 suppress_error = 0;
14787 r = guestfs_umount_all (g);
14793 suppress_error = 0;
14794 r = guestfs_lvm_remove_all (g);
14798 /* TestOutputList for vgs (1) */
14800 char device[] = "/dev/sda";
14801 device[5] = devchar;
14802 char lines_0[] = ",10";
14803 char lines_1[] = ",20";
14804 char lines_2[] = ",";
14812 suppress_error = 0;
14813 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14818 char device[] = "/dev/sda1";
14819 device[5] = devchar;
14821 suppress_error = 0;
14822 r = guestfs_pvcreate (g, device);
14827 char device[] = "/dev/sda2";
14828 device[5] = devchar;
14830 suppress_error = 0;
14831 r = guestfs_pvcreate (g, device);
14836 char device[] = "/dev/sda3";
14837 device[5] = devchar;
14839 suppress_error = 0;
14840 r = guestfs_pvcreate (g, device);
14845 char volgroup[] = "VG1";
14846 char physvols_0[] = "/dev/sda1";
14847 physvols_0[5] = devchar;
14848 char physvols_1[] = "/dev/sda2";
14849 physvols_1[5] = devchar;
14850 char *physvols[] = {
14856 suppress_error = 0;
14857 r = guestfs_vgcreate (g, volgroup, physvols);
14862 char volgroup[] = "VG2";
14863 char physvols_0[] = "/dev/sda3";
14864 physvols_0[5] = devchar;
14865 char *physvols[] = {
14870 suppress_error = 0;
14871 r = guestfs_vgcreate (g, volgroup, physvols);
14878 suppress_error = 0;
14879 r = guestfs_vgs (g);
14883 fprintf (stderr, "test_vgs_1: short list returned from command\n");
14888 char expected[] = "VG1";
14889 if (strcmp (r[0], expected) != 0) {
14890 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14895 fprintf (stderr, "test_vgs_1: short list returned from command\n");
14900 char expected[] = "VG2";
14901 if (strcmp (r[1], expected) != 0) {
14902 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14906 if (r[2] != NULL) {
14907 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
14911 for (i = 0; r[i] != NULL; ++i)
14918 static int test_pvs_0_skip (void)
14922 str = getenv ("SKIP_TEST_PVS_0");
14923 if (str && strcmp (str, "1") == 0) return 1;
14924 str = getenv ("SKIP_TEST_PVS");
14925 if (str && strcmp (str, "1") == 0) return 1;
14929 static int test_pvs_0 (void)
14931 if (test_pvs_0_skip ()) {
14932 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_0");
14936 /* InitBasicFSonLVM for test_pvs_0: create ext2 on /dev/VG/LV */
14938 char device[] = "/dev/sda";
14939 device[5] = devchar;
14941 suppress_error = 0;
14942 r = guestfs_blockdev_setrw (g, device);
14948 suppress_error = 0;
14949 r = guestfs_umount_all (g);
14955 suppress_error = 0;
14956 r = guestfs_lvm_remove_all (g);
14961 char device[] = "/dev/sda";
14962 device[5] = devchar;
14963 char lines_0[] = ",";
14969 suppress_error = 0;
14970 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14975 char device[] = "/dev/sda1";
14976 device[5] = devchar;
14978 suppress_error = 0;
14979 r = guestfs_pvcreate (g, device);
14984 char volgroup[] = "VG";
14985 char physvols_0[] = "/dev/sda1";
14986 physvols_0[5] = devchar;
14987 char *physvols[] = {
14992 suppress_error = 0;
14993 r = guestfs_vgcreate (g, volgroup, physvols);
14998 char logvol[] = "LV";
14999 char volgroup[] = "VG";
15001 suppress_error = 0;
15002 r = guestfs_lvcreate (g, logvol, volgroup, 8);
15007 char fstype[] = "ext2";
15008 char device[] = "/dev/VG/LV";
15010 suppress_error = 0;
15011 r = guestfs_mkfs (g, fstype, device);
15016 char device[] = "/dev/VG/LV";
15017 char mountpoint[] = "/";
15019 suppress_error = 0;
15020 r = guestfs_mount (g, device, mountpoint);
15024 /* TestOutputList for pvs (0) */
15028 suppress_error = 0;
15029 r = guestfs_pvs (g);
15033 fprintf (stderr, "test_pvs_0: short list returned from command\n");
15038 char expected[] = "/dev/sda1";
15039 expected[5] = devchar;
15040 if (strcmp (r[0], expected) != 0) {
15041 fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15045 if (r[1] != NULL) {
15046 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
15050 for (i = 0; r[i] != NULL; ++i)
15057 static int test_pvs_1_skip (void)
15061 str = getenv ("SKIP_TEST_PVS_1");
15062 if (str && strcmp (str, "1") == 0) return 1;
15063 str = getenv ("SKIP_TEST_PVS");
15064 if (str && strcmp (str, "1") == 0) return 1;
15068 static int test_pvs_1 (void)
15070 if (test_pvs_1_skip ()) {
15071 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_1");
15075 /* InitNone|InitEmpty for test_pvs_1 */
15077 char device[] = "/dev/sda";
15078 device[5] = devchar;
15080 suppress_error = 0;
15081 r = guestfs_blockdev_setrw (g, device);
15087 suppress_error = 0;
15088 r = guestfs_umount_all (g);
15094 suppress_error = 0;
15095 r = guestfs_lvm_remove_all (g);
15099 /* TestOutputList for pvs (1) */
15101 char device[] = "/dev/sda";
15102 device[5] = devchar;
15103 char lines_0[] = ",10";
15104 char lines_1[] = ",20";
15105 char lines_2[] = ",";
15113 suppress_error = 0;
15114 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15119 char device[] = "/dev/sda1";
15120 device[5] = devchar;
15122 suppress_error = 0;
15123 r = guestfs_pvcreate (g, device);
15128 char device[] = "/dev/sda2";
15129 device[5] = devchar;
15131 suppress_error = 0;
15132 r = guestfs_pvcreate (g, device);
15137 char device[] = "/dev/sda3";
15138 device[5] = devchar;
15140 suppress_error = 0;
15141 r = guestfs_pvcreate (g, device);
15148 suppress_error = 0;
15149 r = guestfs_pvs (g);
15153 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15158 char expected[] = "/dev/sda1";
15159 expected[5] = devchar;
15160 if (strcmp (r[0], expected) != 0) {
15161 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15166 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15171 char expected[] = "/dev/sda2";
15172 expected[5] = devchar;
15173 if (strcmp (r[1], expected) != 0) {
15174 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15179 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15184 char expected[] = "/dev/sda3";
15185 expected[5] = devchar;
15186 if (strcmp (r[2], expected) != 0) {
15187 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15191 if (r[3] != NULL) {
15192 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
15196 for (i = 0; r[i] != NULL; ++i)
15203 static int test_list_partitions_0_skip (void)
15207 str = getenv ("SKIP_TEST_LIST_PARTITIONS_0");
15208 if (str && strcmp (str, "1") == 0) return 1;
15209 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
15210 if (str && strcmp (str, "1") == 0) return 1;
15214 static int test_list_partitions_0 (void)
15216 if (test_list_partitions_0_skip ()) {
15217 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_0");
15221 /* InitBasicFS for test_list_partitions_0: create ext2 on /dev/sda1 */
15223 char device[] = "/dev/sda";
15224 device[5] = devchar;
15226 suppress_error = 0;
15227 r = guestfs_blockdev_setrw (g, device);
15233 suppress_error = 0;
15234 r = guestfs_umount_all (g);
15240 suppress_error = 0;
15241 r = guestfs_lvm_remove_all (g);
15246 char device[] = "/dev/sda";
15247 device[5] = devchar;
15248 char lines_0[] = ",";
15254 suppress_error = 0;
15255 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15260 char fstype[] = "ext2";
15261 char device[] = "/dev/sda1";
15262 device[5] = devchar;
15264 suppress_error = 0;
15265 r = guestfs_mkfs (g, fstype, device);
15270 char device[] = "/dev/sda1";
15271 device[5] = devchar;
15272 char mountpoint[] = "/";
15274 suppress_error = 0;
15275 r = guestfs_mount (g, device, mountpoint);
15279 /* TestOutputList for list_partitions (0) */
15283 suppress_error = 0;
15284 r = guestfs_list_partitions (g);
15288 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
15293 char expected[] = "/dev/sda1";
15294 expected[5] = devchar;
15295 if (strcmp (r[0], expected) != 0) {
15296 fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15300 if (r[1] != NULL) {
15301 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
15305 for (i = 0; r[i] != NULL; ++i)
15312 static int test_list_partitions_1_skip (void)
15316 str = getenv ("SKIP_TEST_LIST_PARTITIONS_1");
15317 if (str && strcmp (str, "1") == 0) return 1;
15318 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
15319 if (str && strcmp (str, "1") == 0) return 1;
15323 static int test_list_partitions_1 (void)
15325 if (test_list_partitions_1_skip ()) {
15326 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_1");
15330 /* InitNone|InitEmpty for test_list_partitions_1 */
15332 char device[] = "/dev/sda";
15333 device[5] = devchar;
15335 suppress_error = 0;
15336 r = guestfs_blockdev_setrw (g, device);
15342 suppress_error = 0;
15343 r = guestfs_umount_all (g);
15349 suppress_error = 0;
15350 r = guestfs_lvm_remove_all (g);
15354 /* TestOutputList for list_partitions (1) */
15356 char device[] = "/dev/sda";
15357 device[5] = devchar;
15358 char lines_0[] = ",10";
15359 char lines_1[] = ",20";
15360 char lines_2[] = ",";
15368 suppress_error = 0;
15369 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15376 suppress_error = 0;
15377 r = guestfs_list_partitions (g);
15381 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15386 char expected[] = "/dev/sda1";
15387 expected[5] = devchar;
15388 if (strcmp (r[0], expected) != 0) {
15389 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15394 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15399 char expected[] = "/dev/sda2";
15400 expected[5] = devchar;
15401 if (strcmp (r[1], expected) != 0) {
15402 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15407 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15412 char expected[] = "/dev/sda3";
15413 expected[5] = devchar;
15414 if (strcmp (r[2], expected) != 0) {
15415 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15419 if (r[3] != NULL) {
15420 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
15424 for (i = 0; r[i] != NULL; ++i)
15431 static int test_list_devices_0_skip (void)
15435 str = getenv ("SKIP_TEST_LIST_DEVICES_0");
15436 if (str && strcmp (str, "1") == 0) return 1;
15437 str = getenv ("SKIP_TEST_LIST_DEVICES");
15438 if (str && strcmp (str, "1") == 0) return 1;
15442 static int test_list_devices_0 (void)
15444 if (test_list_devices_0_skip ()) {
15445 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_devices_0");
15449 /* InitNone|InitEmpty for test_list_devices_0 */
15451 char device[] = "/dev/sda";
15452 device[5] = devchar;
15454 suppress_error = 0;
15455 r = guestfs_blockdev_setrw (g, device);
15461 suppress_error = 0;
15462 r = guestfs_umount_all (g);
15468 suppress_error = 0;
15469 r = guestfs_lvm_remove_all (g);
15473 /* TestOutputList for list_devices (0) */
15477 suppress_error = 0;
15478 r = guestfs_list_devices (g);
15482 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15487 char expected[] = "/dev/sda";
15488 expected[5] = devchar;
15489 if (strcmp (r[0], expected) != 0) {
15490 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15495 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15500 char expected[] = "/dev/sdb";
15501 expected[5] = devchar;
15502 if (strcmp (r[1], expected) != 0) {
15503 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15508 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15513 char expected[] = "/dev/sdc";
15514 expected[5] = devchar;
15515 if (strcmp (r[2], expected) != 0) {
15516 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15521 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15526 char expected[] = "/dev/sdd";
15527 expected[5] = devchar;
15528 if (strcmp (r[3], expected) != 0) {
15529 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
15533 if (r[4] != NULL) {
15534 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
15538 for (i = 0; r[i] != NULL; ++i)
15545 static int test_ls_0_skip (void)
15549 str = getenv ("SKIP_TEST_LS_0");
15550 if (str && strcmp (str, "1") == 0) return 1;
15551 str = getenv ("SKIP_TEST_LS");
15552 if (str && strcmp (str, "1") == 0) return 1;
15556 static int test_ls_0 (void)
15558 if (test_ls_0_skip ()) {
15559 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ls_0");
15563 /* InitBasicFS for test_ls_0: create ext2 on /dev/sda1 */
15565 char device[] = "/dev/sda";
15566 device[5] = devchar;
15568 suppress_error = 0;
15569 r = guestfs_blockdev_setrw (g, device);
15575 suppress_error = 0;
15576 r = guestfs_umount_all (g);
15582 suppress_error = 0;
15583 r = guestfs_lvm_remove_all (g);
15588 char device[] = "/dev/sda";
15589 device[5] = devchar;
15590 char lines_0[] = ",";
15596 suppress_error = 0;
15597 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15602 char fstype[] = "ext2";
15603 char device[] = "/dev/sda1";
15604 device[5] = devchar;
15606 suppress_error = 0;
15607 r = guestfs_mkfs (g, fstype, device);
15612 char device[] = "/dev/sda1";
15613 device[5] = devchar;
15614 char mountpoint[] = "/";
15616 suppress_error = 0;
15617 r = guestfs_mount (g, device, mountpoint);
15621 /* TestOutputList for ls (0) */
15623 char path[] = "/new";
15625 suppress_error = 0;
15626 r = guestfs_touch (g, path);
15631 char path[] = "/newer";
15633 suppress_error = 0;
15634 r = guestfs_touch (g, path);
15639 char path[] = "/newest";
15641 suppress_error = 0;
15642 r = guestfs_touch (g, path);
15647 char directory[] = "/";
15650 suppress_error = 0;
15651 r = guestfs_ls (g, directory);
15655 fprintf (stderr, "test_ls_0: short list returned from command\n");
15660 char expected[] = "lost+found";
15661 if (strcmp (r[0], expected) != 0) {
15662 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15667 fprintf (stderr, "test_ls_0: short list returned from command\n");
15672 char expected[] = "new";
15673 if (strcmp (r[1], expected) != 0) {
15674 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15679 fprintf (stderr, "test_ls_0: short list returned from command\n");
15684 char expected[] = "newer";
15685 if (strcmp (r[2], expected) != 0) {
15686 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15691 fprintf (stderr, "test_ls_0: short list returned from command\n");
15696 char expected[] = "newest";
15697 if (strcmp (r[3], expected) != 0) {
15698 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
15702 if (r[4] != NULL) {
15703 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
15707 for (i = 0; r[i] != NULL; ++i)
15714 static int test_cat_0_skip (void)
15718 str = getenv ("SKIP_TEST_CAT_0");
15719 if (str && strcmp (str, "1") == 0) return 1;
15720 str = getenv ("SKIP_TEST_CAT");
15721 if (str && strcmp (str, "1") == 0) return 1;
15725 static int test_cat_0 (void)
15727 if (test_cat_0_skip ()) {
15728 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cat_0");
15732 /* InitBasicFS for test_cat_0: create ext2 on /dev/sda1 */
15734 char device[] = "/dev/sda";
15735 device[5] = devchar;
15737 suppress_error = 0;
15738 r = guestfs_blockdev_setrw (g, device);
15744 suppress_error = 0;
15745 r = guestfs_umount_all (g);
15751 suppress_error = 0;
15752 r = guestfs_lvm_remove_all (g);
15757 char device[] = "/dev/sda";
15758 device[5] = devchar;
15759 char lines_0[] = ",";
15765 suppress_error = 0;
15766 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15771 char fstype[] = "ext2";
15772 char device[] = "/dev/sda1";
15773 device[5] = devchar;
15775 suppress_error = 0;
15776 r = guestfs_mkfs (g, fstype, device);
15781 char device[] = "/dev/sda1";
15782 device[5] = devchar;
15783 char mountpoint[] = "/";
15785 suppress_error = 0;
15786 r = guestfs_mount (g, device, mountpoint);
15790 /* TestOutput for cat (0) */
15791 char expected[] = "new file contents";
15793 char path[] = "/new";
15794 char content[] = "new file contents";
15796 suppress_error = 0;
15797 r = guestfs_write_file (g, path, content, 0);
15802 char path[] = "/new";
15804 suppress_error = 0;
15805 r = guestfs_cat (g, path);
15808 if (strcmp (r, expected) != 0) {
15809 fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
15817 static int test_touch_0_skip (void)
15821 str = getenv ("SKIP_TEST_TOUCH_0");
15822 if (str && strcmp (str, "1") == 0) return 1;
15823 str = getenv ("SKIP_TEST_TOUCH");
15824 if (str && strcmp (str, "1") == 0) return 1;
15828 static int test_touch_0 (void)
15830 if (test_touch_0_skip ()) {
15831 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_touch_0");
15835 /* InitBasicFS for test_touch_0: create ext2 on /dev/sda1 */
15837 char device[] = "/dev/sda";
15838 device[5] = devchar;
15840 suppress_error = 0;
15841 r = guestfs_blockdev_setrw (g, device);
15847 suppress_error = 0;
15848 r = guestfs_umount_all (g);
15854 suppress_error = 0;
15855 r = guestfs_lvm_remove_all (g);
15860 char device[] = "/dev/sda";
15861 device[5] = devchar;
15862 char lines_0[] = ",";
15868 suppress_error = 0;
15869 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15874 char fstype[] = "ext2";
15875 char device[] = "/dev/sda1";
15876 device[5] = devchar;
15878 suppress_error = 0;
15879 r = guestfs_mkfs (g, fstype, device);
15884 char device[] = "/dev/sda1";
15885 device[5] = devchar;
15886 char mountpoint[] = "/";
15888 suppress_error = 0;
15889 r = guestfs_mount (g, device, mountpoint);
15893 /* TestOutputTrue for touch (0) */
15895 char path[] = "/new";
15897 suppress_error = 0;
15898 r = guestfs_touch (g, path);
15903 char path[] = "/new";
15905 suppress_error = 0;
15906 r = guestfs_exists (g, path);
15910 fprintf (stderr, "test_touch_0: expected true, got false\n");
15917 static int test_sync_0_skip (void)
15921 str = getenv ("SKIP_TEST_SYNC_0");
15922 if (str && strcmp (str, "1") == 0) return 1;
15923 str = getenv ("SKIP_TEST_SYNC");
15924 if (str && strcmp (str, "1") == 0) return 1;
15928 static int test_sync_0 (void)
15930 if (test_sync_0_skip ()) {
15931 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_sync_0");
15935 /* InitNone|InitEmpty for test_sync_0 */
15937 char device[] = "/dev/sda";
15938 device[5] = devchar;
15940 suppress_error = 0;
15941 r = guestfs_blockdev_setrw (g, device);
15947 suppress_error = 0;
15948 r = guestfs_umount_all (g);
15954 suppress_error = 0;
15955 r = guestfs_lvm_remove_all (g);
15959 /* TestRun for sync (0) */
15962 suppress_error = 0;
15963 r = guestfs_sync (g);
15970 static int test_mount_0_skip (void)
15974 str = getenv ("SKIP_TEST_MOUNT_0");
15975 if (str && strcmp (str, "1") == 0) return 1;
15976 str = getenv ("SKIP_TEST_MOUNT");
15977 if (str && strcmp (str, "1") == 0) return 1;
15981 static int test_mount_0 (void)
15983 if (test_mount_0_skip ()) {
15984 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_0");
15988 /* InitNone|InitEmpty for test_mount_0 */
15990 char device[] = "/dev/sda";
15991 device[5] = devchar;
15993 suppress_error = 0;
15994 r = guestfs_blockdev_setrw (g, device);
16000 suppress_error = 0;
16001 r = guestfs_umount_all (g);
16007 suppress_error = 0;
16008 r = guestfs_lvm_remove_all (g);
16012 /* TestOutput for mount (0) */
16013 char expected[] = "new file contents";
16015 char device[] = "/dev/sda";
16016 device[5] = devchar;
16017 char lines_0[] = ",";
16023 suppress_error = 0;
16024 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
16029 char fstype[] = "ext2";
16030 char device[] = "/dev/sda1";
16031 device[5] = devchar;
16033 suppress_error = 0;
16034 r = guestfs_mkfs (g, fstype, device);
16039 char device[] = "/dev/sda1";
16040 device[5] = devchar;
16041 char mountpoint[] = "/";
16043 suppress_error = 0;
16044 r = guestfs_mount (g, device, mountpoint);
16049 char path[] = "/new";
16050 char content[] = "new file contents";
16052 suppress_error = 0;
16053 r = guestfs_write_file (g, path, content, 0);
16058 char path[] = "/new";
16060 suppress_error = 0;
16061 r = guestfs_cat (g, path);
16064 if (strcmp (r, expected) != 0) {
16065 fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
16073 int main (int argc, char *argv[])
16077 const char *filename;
16079 int nr_tests, test_num = 0;
16082 no_test_warnings ();
16084 g = guestfs_create ();
16086 printf ("guestfs_create FAILED\n");
16090 guestfs_set_error_handler (g, print_error, NULL);
16092 guestfs_set_path (g, "../appliance");
16094 filename = "test1.img";
16095 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16100 if (lseek (fd, 524288000, SEEK_SET) == -1) {
16106 if (write (fd, &c, 1) == -1) {
16112 if (close (fd) == -1) {
16117 if (guestfs_add_drive (g, filename) == -1) {
16118 printf ("guestfs_add_drive %s FAILED\n", filename);
16122 filename = "test2.img";
16123 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16128 if (lseek (fd, 52428800, SEEK_SET) == -1) {
16134 if (write (fd, &c, 1) == -1) {
16140 if (close (fd) == -1) {
16145 if (guestfs_add_drive (g, filename) == -1) {
16146 printf ("guestfs_add_drive %s FAILED\n", filename);
16150 filename = "test3.img";
16151 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16156 if (lseek (fd, 10485760, SEEK_SET) == -1) {
16162 if (write (fd, &c, 1) == -1) {
16168 if (close (fd) == -1) {
16173 if (guestfs_add_drive (g, filename) == -1) {
16174 printf ("guestfs_add_drive %s FAILED\n", filename);
16178 if (guestfs_add_drive_ro (g, "../images/test.sqsh") == -1) {
16179 printf ("guestfs_add_drive_ro ../images/test.sqsh FAILED\n");
16183 if (guestfs_launch (g) == -1) {
16184 printf ("guestfs_launch FAILED\n");
16187 if (guestfs_wait_ready (g) == -1) {
16188 printf ("guestfs_wait_ready FAILED\n");
16192 /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
16193 * names. This changed between RHEL 5 and RHEL 6 so we have to
16196 devs = guestfs_list_devices (g);
16197 if (devs == NULL || devs[0] == NULL) {
16198 printf ("guestfs_list_devices FAILED\n");
16201 if (strncmp (devs[0], "/dev/sd", 7) == 0)
16203 else if (strncmp (devs[0], "/dev/hd", 7) == 0)
16206 printf ("guestfs_list_devices returned unexpected string '%s'\n",
16210 for (i = 0; devs[i] != NULL; ++i)
16217 printf ("%3d/%3d test_sleep_0\n", test_num, nr_tests);
16218 if (test_sleep_0 () == -1) {
16219 printf ("test_sleep_0 FAILED\n");
16223 printf ("%3d/%3d test_find_0\n", test_num, nr_tests);
16224 if (test_find_0 () == -1) {
16225 printf ("test_find_0 FAILED\n");
16229 printf ("%3d/%3d test_find_1\n", test_num, nr_tests);
16230 if (test_find_1 () == -1) {
16231 printf ("test_find_1 FAILED\n");
16235 printf ("%3d/%3d test_find_2\n", test_num, nr_tests);
16236 if (test_find_2 () == -1) {
16237 printf ("test_find_2 FAILED\n");
16241 printf ("%3d/%3d test_lvresize_0\n", test_num, nr_tests);
16242 if (test_lvresize_0 () == -1) {
16243 printf ("test_lvresize_0 FAILED\n");
16247 printf ("%3d/%3d test_zerofree_0\n", test_num, nr_tests);
16248 if (test_zerofree_0 () == -1) {
16249 printf ("test_zerofree_0 FAILED\n");
16253 printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
16254 if (test_hexdump_0 () == -1) {
16255 printf ("test_hexdump_0 FAILED\n");
16259 printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
16260 if (test_strings_e_0 () == -1) {
16261 printf ("test_strings_e_0 FAILED\n");
16265 printf ("%3d/%3d test_strings_e_1\n", test_num, nr_tests);
16266 if (test_strings_e_1 () == -1) {
16267 printf ("test_strings_e_1 FAILED\n");
16271 printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
16272 if (test_strings_0 () == -1) {
16273 printf ("test_strings_0 FAILED\n");
16277 printf ("%3d/%3d test_strings_1\n", test_num, nr_tests);
16278 if (test_strings_1 () == -1) {
16279 printf ("test_strings_1 FAILED\n");
16283 printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
16284 if (test_equal_0 () == -1) {
16285 printf ("test_equal_0 FAILED\n");
16289 printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
16290 if (test_equal_1 () == -1) {
16291 printf ("test_equal_1 FAILED\n");
16295 printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
16296 if (test_equal_2 () == -1) {
16297 printf ("test_equal_2 FAILED\n");
16301 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
16302 if (test_ping_daemon_0 () == -1) {
16303 printf ("test_ping_daemon_0 FAILED\n");
16307 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
16308 if (test_dmesg_0 () == -1) {
16309 printf ("test_dmesg_0 FAILED\n");
16313 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
16314 if (test_drop_caches_0 () == -1) {
16315 printf ("test_drop_caches_0 FAILED\n");
16319 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
16320 if (test_mv_0 () == -1) {
16321 printf ("test_mv_0 FAILED\n");
16325 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
16326 if (test_mv_1 () == -1) {
16327 printf ("test_mv_1 FAILED\n");
16331 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
16332 if (test_cp_a_0 () == -1) {
16333 printf ("test_cp_a_0 FAILED\n");
16337 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
16338 if (test_cp_0 () == -1) {
16339 printf ("test_cp_0 FAILED\n");
16343 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
16344 if (test_cp_1 () == -1) {
16345 printf ("test_cp_1 FAILED\n");
16349 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
16350 if (test_cp_2 () == -1) {
16351 printf ("test_cp_2 FAILED\n");
16355 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
16356 if (test_grub_install_0 () == -1) {
16357 printf ("test_grub_install_0 FAILED\n");
16361 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
16362 if (test_zero_0 () == -1) {
16363 printf ("test_zero_0 FAILED\n");
16367 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
16368 if (test_fsck_0 () == -1) {
16369 printf ("test_fsck_0 FAILED\n");
16373 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
16374 if (test_fsck_1 () == -1) {
16375 printf ("test_fsck_1 FAILED\n");
16379 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
16380 if (test_set_e2uuid_0 () == -1) {
16381 printf ("test_set_e2uuid_0 FAILED\n");
16385 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
16386 if (test_set_e2uuid_1 () == -1) {
16387 printf ("test_set_e2uuid_1 FAILED\n");
16391 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
16392 if (test_set_e2uuid_2 () == -1) {
16393 printf ("test_set_e2uuid_2 FAILED\n");
16397 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
16398 if (test_set_e2uuid_3 () == -1) {
16399 printf ("test_set_e2uuid_3 FAILED\n");
16403 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
16404 if (test_set_e2label_0 () == -1) {
16405 printf ("test_set_e2label_0 FAILED\n");
16409 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
16410 if (test_pvremove_0 () == -1) {
16411 printf ("test_pvremove_0 FAILED\n");
16415 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
16416 if (test_pvremove_1 () == -1) {
16417 printf ("test_pvremove_1 FAILED\n");
16421 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
16422 if (test_pvremove_2 () == -1) {
16423 printf ("test_pvremove_2 FAILED\n");
16427 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
16428 if (test_vgremove_0 () == -1) {
16429 printf ("test_vgremove_0 FAILED\n");
16433 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
16434 if (test_vgremove_1 () == -1) {
16435 printf ("test_vgremove_1 FAILED\n");
16439 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
16440 if (test_lvremove_0 () == -1) {
16441 printf ("test_lvremove_0 FAILED\n");
16445 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
16446 if (test_lvremove_1 () == -1) {
16447 printf ("test_lvremove_1 FAILED\n");
16451 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
16452 if (test_lvremove_2 () == -1) {
16453 printf ("test_lvremove_2 FAILED\n");
16457 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
16458 if (test_mount_ro_0 () == -1) {
16459 printf ("test_mount_ro_0 FAILED\n");
16463 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
16464 if (test_mount_ro_1 () == -1) {
16465 printf ("test_mount_ro_1 FAILED\n");
16469 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
16470 if (test_tgz_in_0 () == -1) {
16471 printf ("test_tgz_in_0 FAILED\n");
16475 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
16476 if (test_tar_in_0 () == -1) {
16477 printf ("test_tar_in_0 FAILED\n");
16481 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
16482 if (test_checksum_0 () == -1) {
16483 printf ("test_checksum_0 FAILED\n");
16487 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
16488 if (test_checksum_1 () == -1) {
16489 printf ("test_checksum_1 FAILED\n");
16493 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
16494 if (test_checksum_2 () == -1) {
16495 printf ("test_checksum_2 FAILED\n");
16499 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
16500 if (test_checksum_3 () == -1) {
16501 printf ("test_checksum_3 FAILED\n");
16505 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
16506 if (test_checksum_4 () == -1) {
16507 printf ("test_checksum_4 FAILED\n");
16511 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
16512 if (test_checksum_5 () == -1) {
16513 printf ("test_checksum_5 FAILED\n");
16517 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
16518 if (test_checksum_6 () == -1) {
16519 printf ("test_checksum_6 FAILED\n");
16523 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
16524 if (test_checksum_7 () == -1) {
16525 printf ("test_checksum_7 FAILED\n");
16529 printf ("%3d/%3d test_checksum_8\n", test_num, nr_tests);
16530 if (test_checksum_8 () == -1) {
16531 printf ("test_checksum_8 FAILED\n");
16535 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
16536 if (test_download_0 () == -1) {
16537 printf ("test_download_0 FAILED\n");
16541 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
16542 if (test_upload_0 () == -1) {
16543 printf ("test_upload_0 FAILED\n");
16547 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
16548 if (test_blockdev_rereadpt_0 () == -1) {
16549 printf ("test_blockdev_rereadpt_0 FAILED\n");
16553 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
16554 if (test_blockdev_flushbufs_0 () == -1) {
16555 printf ("test_blockdev_flushbufs_0 FAILED\n");
16559 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
16560 if (test_blockdev_getsize64_0 () == -1) {
16561 printf ("test_blockdev_getsize64_0 FAILED\n");
16565 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
16566 if (test_blockdev_getsz_0 () == -1) {
16567 printf ("test_blockdev_getsz_0 FAILED\n");
16571 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
16572 if (test_blockdev_getbsz_0 () == -1) {
16573 printf ("test_blockdev_getbsz_0 FAILED\n");
16577 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
16578 if (test_blockdev_getss_0 () == -1) {
16579 printf ("test_blockdev_getss_0 FAILED\n");
16583 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
16584 if (test_blockdev_getro_0 () == -1) {
16585 printf ("test_blockdev_getro_0 FAILED\n");
16589 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
16590 if (test_blockdev_setrw_0 () == -1) {
16591 printf ("test_blockdev_setrw_0 FAILED\n");
16595 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
16596 if (test_blockdev_setro_0 () == -1) {
16597 printf ("test_blockdev_setro_0 FAILED\n");
16601 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
16602 if (test_statvfs_0 () == -1) {
16603 printf ("test_statvfs_0 FAILED\n");
16607 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
16608 if (test_lstat_0 () == -1) {
16609 printf ("test_lstat_0 FAILED\n");
16613 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
16614 if (test_stat_0 () == -1) {
16615 printf ("test_stat_0 FAILED\n");
16619 printf ("%3d/%3d test_command_lines_0\n", test_num, nr_tests);
16620 if (test_command_lines_0 () == -1) {
16621 printf ("test_command_lines_0 FAILED\n");
16625 printf ("%3d/%3d test_command_lines_1\n", test_num, nr_tests);
16626 if (test_command_lines_1 () == -1) {
16627 printf ("test_command_lines_1 FAILED\n");
16631 printf ("%3d/%3d test_command_lines_2\n", test_num, nr_tests);
16632 if (test_command_lines_2 () == -1) {
16633 printf ("test_command_lines_2 FAILED\n");
16637 printf ("%3d/%3d test_command_lines_3\n", test_num, nr_tests);
16638 if (test_command_lines_3 () == -1) {
16639 printf ("test_command_lines_3 FAILED\n");
16643 printf ("%3d/%3d test_command_lines_4\n", test_num, nr_tests);
16644 if (test_command_lines_4 () == -1) {
16645 printf ("test_command_lines_4 FAILED\n");
16649 printf ("%3d/%3d test_command_lines_5\n", test_num, nr_tests);
16650 if (test_command_lines_5 () == -1) {
16651 printf ("test_command_lines_5 FAILED\n");
16655 printf ("%3d/%3d test_command_lines_6\n", test_num, nr_tests);
16656 if (test_command_lines_6 () == -1) {
16657 printf ("test_command_lines_6 FAILED\n");
16661 printf ("%3d/%3d test_command_lines_7\n", test_num, nr_tests);
16662 if (test_command_lines_7 () == -1) {
16663 printf ("test_command_lines_7 FAILED\n");
16667 printf ("%3d/%3d test_command_lines_8\n", test_num, nr_tests);
16668 if (test_command_lines_8 () == -1) {
16669 printf ("test_command_lines_8 FAILED\n");
16673 printf ("%3d/%3d test_command_lines_9\n", test_num, nr_tests);
16674 if (test_command_lines_9 () == -1) {
16675 printf ("test_command_lines_9 FAILED\n");
16679 printf ("%3d/%3d test_command_lines_10\n", test_num, nr_tests);
16680 if (test_command_lines_10 () == -1) {
16681 printf ("test_command_lines_10 FAILED\n");
16685 printf ("%3d/%3d test_command_0\n", test_num, nr_tests);
16686 if (test_command_0 () == -1) {
16687 printf ("test_command_0 FAILED\n");
16691 printf ("%3d/%3d test_command_1\n", test_num, nr_tests);
16692 if (test_command_1 () == -1) {
16693 printf ("test_command_1 FAILED\n");
16697 printf ("%3d/%3d test_command_2\n", test_num, nr_tests);
16698 if (test_command_2 () == -1) {
16699 printf ("test_command_2 FAILED\n");
16703 printf ("%3d/%3d test_command_3\n", test_num, nr_tests);
16704 if (test_command_3 () == -1) {
16705 printf ("test_command_3 FAILED\n");
16709 printf ("%3d/%3d test_command_4\n", test_num, nr_tests);
16710 if (test_command_4 () == -1) {
16711 printf ("test_command_4 FAILED\n");
16715 printf ("%3d/%3d test_command_5\n", test_num, nr_tests);
16716 if (test_command_5 () == -1) {
16717 printf ("test_command_5 FAILED\n");
16721 printf ("%3d/%3d test_command_6\n", test_num, nr_tests);
16722 if (test_command_6 () == -1) {
16723 printf ("test_command_6 FAILED\n");
16727 printf ("%3d/%3d test_command_7\n", test_num, nr_tests);
16728 if (test_command_7 () == -1) {
16729 printf ("test_command_7 FAILED\n");
16733 printf ("%3d/%3d test_command_8\n", test_num, nr_tests);
16734 if (test_command_8 () == -1) {
16735 printf ("test_command_8 FAILED\n");
16739 printf ("%3d/%3d test_command_9\n", test_num, nr_tests);
16740 if (test_command_9 () == -1) {
16741 printf ("test_command_9 FAILED\n");
16745 printf ("%3d/%3d test_command_10\n", test_num, nr_tests);
16746 if (test_command_10 () == -1) {
16747 printf ("test_command_10 FAILED\n");
16751 printf ("%3d/%3d test_command_11\n", test_num, nr_tests);
16752 if (test_command_11 () == -1) {
16753 printf ("test_command_11 FAILED\n");
16757 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
16758 if (test_file_0 () == -1) {
16759 printf ("test_file_0 FAILED\n");
16763 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
16764 if (test_file_1 () == -1) {
16765 printf ("test_file_1 FAILED\n");
16769 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
16770 if (test_file_2 () == -1) {
16771 printf ("test_file_2 FAILED\n");
16775 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
16776 if (test_umount_all_0 () == -1) {
16777 printf ("test_umount_all_0 FAILED\n");
16781 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
16782 if (test_umount_all_1 () == -1) {
16783 printf ("test_umount_all_1 FAILED\n");
16787 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
16788 if (test_mounts_0 () == -1) {
16789 printf ("test_mounts_0 FAILED\n");
16793 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
16794 if (test_umount_0 () == -1) {
16795 printf ("test_umount_0 FAILED\n");
16799 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
16800 if (test_umount_1 () == -1) {
16801 printf ("test_umount_1 FAILED\n");
16805 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
16806 if (test_write_file_0 () == -1) {
16807 printf ("test_write_file_0 FAILED\n");
16811 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
16812 if (test_write_file_1 () == -1) {
16813 printf ("test_write_file_1 FAILED\n");
16817 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
16818 if (test_write_file_2 () == -1) {
16819 printf ("test_write_file_2 FAILED\n");
16823 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
16824 if (test_write_file_3 () == -1) {
16825 printf ("test_write_file_3 FAILED\n");
16829 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
16830 if (test_write_file_4 () == -1) {
16831 printf ("test_write_file_4 FAILED\n");
16835 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
16836 if (test_write_file_5 () == -1) {
16837 printf ("test_write_file_5 FAILED\n");
16841 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
16842 if (test_mkfs_0 () == -1) {
16843 printf ("test_mkfs_0 FAILED\n");
16847 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
16848 if (test_lvcreate_0 () == -1) {
16849 printf ("test_lvcreate_0 FAILED\n");
16853 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
16854 if (test_vgcreate_0 () == -1) {
16855 printf ("test_vgcreate_0 FAILED\n");
16859 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
16860 if (test_pvcreate_0 () == -1) {
16861 printf ("test_pvcreate_0 FAILED\n");
16865 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
16866 if (test_is_dir_0 () == -1) {
16867 printf ("test_is_dir_0 FAILED\n");
16871 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
16872 if (test_is_dir_1 () == -1) {
16873 printf ("test_is_dir_1 FAILED\n");
16877 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
16878 if (test_is_file_0 () == -1) {
16879 printf ("test_is_file_0 FAILED\n");
16883 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
16884 if (test_is_file_1 () == -1) {
16885 printf ("test_is_file_1 FAILED\n");
16889 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
16890 if (test_exists_0 () == -1) {
16891 printf ("test_exists_0 FAILED\n");
16895 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
16896 if (test_exists_1 () == -1) {
16897 printf ("test_exists_1 FAILED\n");
16901 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
16902 if (test_mkdir_p_0 () == -1) {
16903 printf ("test_mkdir_p_0 FAILED\n");
16907 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
16908 if (test_mkdir_p_1 () == -1) {
16909 printf ("test_mkdir_p_1 FAILED\n");
16913 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
16914 if (test_mkdir_p_2 () == -1) {
16915 printf ("test_mkdir_p_2 FAILED\n");
16919 printf ("%3d/%3d test_mkdir_p_3\n", test_num, nr_tests);
16920 if (test_mkdir_p_3 () == -1) {
16921 printf ("test_mkdir_p_3 FAILED\n");
16925 printf ("%3d/%3d test_mkdir_p_4\n", test_num, nr_tests);
16926 if (test_mkdir_p_4 () == -1) {
16927 printf ("test_mkdir_p_4 FAILED\n");
16931 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
16932 if (test_mkdir_0 () == -1) {
16933 printf ("test_mkdir_0 FAILED\n");
16937 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
16938 if (test_mkdir_1 () == -1) {
16939 printf ("test_mkdir_1 FAILED\n");
16943 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
16944 if (test_rm_rf_0 () == -1) {
16945 printf ("test_rm_rf_0 FAILED\n");
16949 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
16950 if (test_rmdir_0 () == -1) {
16951 printf ("test_rmdir_0 FAILED\n");
16955 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
16956 if (test_rmdir_1 () == -1) {
16957 printf ("test_rmdir_1 FAILED\n");
16961 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
16962 if (test_rmdir_2 () == -1) {
16963 printf ("test_rmdir_2 FAILED\n");
16967 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
16968 if (test_rm_0 () == -1) {
16969 printf ("test_rm_0 FAILED\n");
16973 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
16974 if (test_rm_1 () == -1) {
16975 printf ("test_rm_1 FAILED\n");
16979 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
16980 if (test_rm_2 () == -1) {
16981 printf ("test_rm_2 FAILED\n");
16985 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
16986 if (test_read_lines_0 () == -1) {
16987 printf ("test_read_lines_0 FAILED\n");
16991 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
16992 if (test_read_lines_1 () == -1) {
16993 printf ("test_read_lines_1 FAILED\n");
16997 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
16998 if (test_lvs_0 () == -1) {
16999 printf ("test_lvs_0 FAILED\n");
17003 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
17004 if (test_lvs_1 () == -1) {
17005 printf ("test_lvs_1 FAILED\n");
17009 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
17010 if (test_vgs_0 () == -1) {
17011 printf ("test_vgs_0 FAILED\n");
17015 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
17016 if (test_vgs_1 () == -1) {
17017 printf ("test_vgs_1 FAILED\n");
17021 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
17022 if (test_pvs_0 () == -1) {
17023 printf ("test_pvs_0 FAILED\n");
17027 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
17028 if (test_pvs_1 () == -1) {
17029 printf ("test_pvs_1 FAILED\n");
17033 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
17034 if (test_list_partitions_0 () == -1) {
17035 printf ("test_list_partitions_0 FAILED\n");
17039 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
17040 if (test_list_partitions_1 () == -1) {
17041 printf ("test_list_partitions_1 FAILED\n");
17045 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
17046 if (test_list_devices_0 () == -1) {
17047 printf ("test_list_devices_0 FAILED\n");
17051 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
17052 if (test_ls_0 () == -1) {
17053 printf ("test_ls_0 FAILED\n");
17057 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
17058 if (test_cat_0 () == -1) {
17059 printf ("test_cat_0 FAILED\n");
17063 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
17064 if (test_touch_0 () == -1) {
17065 printf ("test_touch_0 FAILED\n");
17069 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
17070 if (test_sync_0 () == -1) {
17071 printf ("test_sync_0 FAILED\n");
17075 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
17076 if (test_mount_0 () == -1) {
17077 printf ("test_mount_0 FAILED\n");
17082 unlink ("test1.img");
17083 unlink ("test2.img");
17084 unlink ("test3.img");
17087 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);