1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
32 static int suppress_error = 0;
34 /* This will be 's' or 'h' depending on whether the guest kernel
35 * names IDE devices /dev/sd* or /dev/hd*.
37 static char devchar = 's';
39 static void print_error (guestfs_h *g, void *data, const char *msg)
42 fprintf (stderr, "%s\n", msg);
45 static void print_strings (char * const * const argv)
49 for (argc = 0; argv[argc] != NULL; ++argc)
50 printf ("\t%s\n", argv[argc]);
54 static void print_table (char * const * const argv)
58 for (i = 0; argv[i] != NULL; i += 2)
59 printf ("%s: %s\n", argv[i], argv[i+1]);
63 static void no_test_warnings (void)
65 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_set_append\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_get_append\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
111 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
112 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
113 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
114 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
115 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
116 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
117 fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
118 fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
119 fprintf (stderr, "warning: \"guestfs_pvresize\" has no tests\n");
120 fprintf (stderr, "warning: \"guestfs_sfdisk_N\" has no tests\n");
121 fprintf (stderr, "warning: \"guestfs_sfdisk_l\" has no tests\n");
122 fprintf (stderr, "warning: \"guestfs_sfdisk_kernel_geometry\" has no tests\n");
123 fprintf (stderr, "warning: \"guestfs_sfdisk_disk_geometry\" has no tests\n");
124 fprintf (stderr, "warning: \"guestfs_vg_activate_all\" has no tests\n");
125 fprintf (stderr, "warning: \"guestfs_vg_activate\" has no tests\n");
126 fprintf (stderr, "warning: \"guestfs_resize2fs\" has no tests\n");
127 fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
130 static int test_find_0_skip (void)
134 str = getenv ("SKIP_TEST_FIND_0");
135 if (str && strcmp (str, "1") == 0) return 1;
136 str = getenv ("SKIP_TEST_FIND");
137 if (str && strcmp (str, "1") == 0) return 1;
141 static int test_find_0 (void)
143 if (test_find_0_skip ()) {
144 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_0");
148 /* InitBasicFS for test_find_0: create ext2 on /dev/sda1 */
150 char device[] = "/dev/sda";
154 r = guestfs_blockdev_setrw (g, device);
161 r = guestfs_umount_all (g);
168 r = guestfs_lvm_remove_all (g);
173 char device[] = "/dev/sda";
175 char lines_0[] = ",";
182 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
187 char fstype[] = "ext2";
188 char device[] = "/dev/sda1";
192 r = guestfs_mkfs (g, fstype, device);
197 char device[] = "/dev/sda1";
199 char mountpoint[] = "/";
202 r = guestfs_mount (g, device, mountpoint);
206 /* TestOutputList for find (0) */
208 char directory[] = "/";
212 r = guestfs_find (g, directory);
216 fprintf (stderr, "test_find_0: short list returned from command\n");
221 char expected[] = "lost+found";
222 if (strcmp (r[0], expected) != 0) {
223 fprintf (stderr, "test_find_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
228 fprintf (stderr, "test_find_0: extra elements returned from command\n");
232 for (i = 0; r[i] != NULL; ++i)
239 static int test_find_1_skip (void)
243 str = getenv ("SKIP_TEST_FIND_1");
244 if (str && strcmp (str, "1") == 0) return 1;
245 str = getenv ("SKIP_TEST_FIND");
246 if (str && strcmp (str, "1") == 0) return 1;
250 static int test_find_1 (void)
252 if (test_find_1_skip ()) {
253 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_1");
257 /* InitBasicFS for test_find_1: create ext2 on /dev/sda1 */
259 char device[] = "/dev/sda";
263 r = guestfs_blockdev_setrw (g, device);
270 r = guestfs_umount_all (g);
277 r = guestfs_lvm_remove_all (g);
282 char device[] = "/dev/sda";
284 char lines_0[] = ",";
291 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
296 char fstype[] = "ext2";
297 char device[] = "/dev/sda1";
301 r = guestfs_mkfs (g, fstype, device);
306 char device[] = "/dev/sda1";
308 char mountpoint[] = "/";
311 r = guestfs_mount (g, device, mountpoint);
315 /* TestOutputList for find (1) */
320 r = guestfs_touch (g, path);
328 r = guestfs_mkdir (g, path);
333 char path[] = "/b/c";
336 r = guestfs_touch (g, path);
341 char directory[] = "/";
345 r = guestfs_find (g, directory);
349 fprintf (stderr, "test_find_1: short list returned from command\n");
354 char expected[] = "a";
355 if (strcmp (r[0], expected) != 0) {
356 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
361 fprintf (stderr, "test_find_1: short list returned from command\n");
366 char expected[] = "b";
367 if (strcmp (r[1], expected) != 0) {
368 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
373 fprintf (stderr, "test_find_1: short list returned from command\n");
378 char expected[] = "b/c";
379 if (strcmp (r[2], expected) != 0) {
380 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
385 fprintf (stderr, "test_find_1: short list returned from command\n");
390 char expected[] = "lost+found";
391 if (strcmp (r[3], expected) != 0) {
392 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[3]);
397 fprintf (stderr, "test_find_1: extra elements returned from command\n");
401 for (i = 0; r[i] != NULL; ++i)
408 static int test_find_2_skip (void)
412 str = getenv ("SKIP_TEST_FIND_2");
413 if (str && strcmp (str, "1") == 0) return 1;
414 str = getenv ("SKIP_TEST_FIND");
415 if (str && strcmp (str, "1") == 0) return 1;
419 static int test_find_2 (void)
421 if (test_find_2_skip ()) {
422 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_2");
426 /* InitBasicFS for test_find_2: create ext2 on /dev/sda1 */
428 char device[] = "/dev/sda";
432 r = guestfs_blockdev_setrw (g, device);
439 r = guestfs_umount_all (g);
446 r = guestfs_lvm_remove_all (g);
451 char device[] = "/dev/sda";
453 char lines_0[] = ",";
460 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
465 char fstype[] = "ext2";
466 char device[] = "/dev/sda1";
470 r = guestfs_mkfs (g, fstype, device);
475 char device[] = "/dev/sda1";
477 char mountpoint[] = "/";
480 r = guestfs_mount (g, device, mountpoint);
484 /* TestOutputList for find (2) */
486 char path[] = "/a/b/c";
489 r = guestfs_mkdir_p (g, path);
494 char path[] = "/a/b/c/d";
497 r = guestfs_touch (g, path);
502 char directory[] = "/a/b/";
506 r = guestfs_find (g, directory);
510 fprintf (stderr, "test_find_2: short list returned from command\n");
515 char expected[] = "c";
516 if (strcmp (r[0], expected) != 0) {
517 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
522 fprintf (stderr, "test_find_2: short list returned from command\n");
527 char expected[] = "c/d";
528 if (strcmp (r[1], expected) != 0) {
529 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
534 fprintf (stderr, "test_find_2: extra elements returned from command\n");
538 for (i = 0; r[i] != NULL; ++i)
545 static int test_lvresize_0_skip (void)
549 str = getenv ("SKIP_TEST_LVRESIZE_0");
550 if (str && strcmp (str, "1") == 0) return 1;
551 str = getenv ("SKIP_TEST_LVRESIZE");
552 if (str && strcmp (str, "1") == 0) return 1;
556 static int test_lvresize_0 (void)
558 if (test_lvresize_0_skip ()) {
559 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvresize_0");
563 /* InitNone|InitEmpty for test_lvresize_0 */
565 char device[] = "/dev/sda";
569 r = guestfs_blockdev_setrw (g, device);
576 r = guestfs_umount_all (g);
583 r = guestfs_lvm_remove_all (g);
587 /* TestOutput for lvresize (0) */
588 char expected[] = "test content";
590 char device[] = "/dev/sda";
592 char lines_0[] = ",";
599 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
604 char device[] = "/dev/sda1";
608 r = guestfs_pvcreate (g, device);
613 char volgroup[] = "VG";
614 char physvols_0[] = "/dev/sda1";
615 physvols_0[5] = devchar;
622 r = guestfs_vgcreate (g, volgroup, physvols);
627 char logvol[] = "LV";
628 char volgroup[] = "VG";
631 r = guestfs_lvcreate (g, logvol, volgroup, 10);
636 char fstype[] = "ext2";
637 char device[] = "/dev/VG/LV";
640 r = guestfs_mkfs (g, fstype, device);
645 char device[] = "/dev/VG/LV";
646 char mountpoint[] = "/";
649 r = guestfs_mount (g, device, mountpoint);
654 char path[] = "/new";
655 char content[] = "test content";
658 r = guestfs_write_file (g, path, content, 0);
663 char pathordevice[] = "/";
666 r = guestfs_umount (g, pathordevice);
671 char device[] = "/dev/VG/LV";
674 r = guestfs_lvresize (g, device, 20);
679 char device[] = "/dev/VG/LV";
682 r = guestfs_e2fsck_f (g, device);
687 char device[] = "/dev/VG/LV";
690 r = guestfs_resize2fs (g, device);
695 char device[] = "/dev/VG/LV";
696 char mountpoint[] = "/";
699 r = guestfs_mount (g, device, mountpoint);
704 char path[] = "/new";
707 r = guestfs_cat (g, path);
710 if (strcmp (r, expected) != 0) {
711 fprintf (stderr, "test_lvresize_0: expected \"%s\" but got \"%s\"\n", expected, r);
719 static int test_zerofree_0_skip (void)
723 str = getenv ("SKIP_TEST_ZEROFREE_0");
724 if (str && strcmp (str, "1") == 0) return 1;
725 str = getenv ("SKIP_TEST_ZEROFREE");
726 if (str && strcmp (str, "1") == 0) return 1;
730 static int test_zerofree_0 (void)
732 if (test_zerofree_0_skip ()) {
733 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zerofree_0");
737 /* InitNone|InitEmpty for test_zerofree_0 */
739 char device[] = "/dev/sda";
743 r = guestfs_blockdev_setrw (g, device);
750 r = guestfs_umount_all (g);
757 r = guestfs_lvm_remove_all (g);
761 /* TestOutput for zerofree (0) */
762 char expected[] = "test file";
764 char device[] = "/dev/sda";
766 char lines_0[] = ",";
773 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
778 char fstype[] = "ext3";
779 char device[] = "/dev/sda1";
783 r = guestfs_mkfs (g, fstype, device);
788 char device[] = "/dev/sda1";
790 char mountpoint[] = "/";
793 r = guestfs_mount (g, device, mountpoint);
798 char path[] = "/new";
799 char content[] = "test file";
802 r = guestfs_write_file (g, path, content, 0);
807 char pathordevice[] = "/dev/sda1";
808 pathordevice[5] = devchar;
811 r = guestfs_umount (g, pathordevice);
816 char device[] = "/dev/sda1";
820 r = guestfs_zerofree (g, device);
825 char device[] = "/dev/sda1";
827 char mountpoint[] = "/";
830 r = guestfs_mount (g, device, mountpoint);
835 char path[] = "/new";
838 r = guestfs_cat (g, path);
841 if (strcmp (r, expected) != 0) {
842 fprintf (stderr, "test_zerofree_0: expected \"%s\" but got \"%s\"\n", expected, r);
850 static int test_hexdump_0_skip (void)
854 str = getenv ("SKIP_TEST_HEXDUMP_0");
855 if (str && strcmp (str, "1") == 0) return 1;
856 str = getenv ("SKIP_TEST_HEXDUMP");
857 if (str && strcmp (str, "1") == 0) return 1;
861 static int test_hexdump_0 (void)
863 if (test_hexdump_0_skip ()) {
864 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_hexdump_0");
868 /* InitBasicFS for test_hexdump_0: create ext2 on /dev/sda1 */
870 char device[] = "/dev/sda";
874 r = guestfs_blockdev_setrw (g, device);
881 r = guestfs_umount_all (g);
888 r = guestfs_lvm_remove_all (g);
893 char device[] = "/dev/sda";
895 char lines_0[] = ",";
902 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
907 char fstype[] = "ext2";
908 char device[] = "/dev/sda1";
912 r = guestfs_mkfs (g, fstype, device);
917 char device[] = "/dev/sda1";
919 char mountpoint[] = "/";
922 r = guestfs_mount (g, device, mountpoint);
926 /* TestOutput for hexdump (0) */
927 char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
929 char path[] = "/new";
930 char content[] = "hello\nworld\n";
933 r = guestfs_write_file (g, path, content, 12);
938 char path[] = "/new";
941 r = guestfs_hexdump (g, path);
944 if (strcmp (r, expected) != 0) {
945 fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
953 static int test_strings_e_0_skip (void)
957 str = getenv ("SKIP_TEST_STRINGS_E_0");
958 if (str && strcmp (str, "1") == 0) return 1;
959 str = getenv ("SKIP_TEST_STRINGS_E");
960 if (str && strcmp (str, "1") == 0) return 1;
964 static int test_strings_e_0 (void)
966 if (test_strings_e_0_skip ()) {
967 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_0");
971 /* InitBasicFS for test_strings_e_0: create ext2 on /dev/sda1 */
973 char device[] = "/dev/sda";
977 r = guestfs_blockdev_setrw (g, device);
984 r = guestfs_umount_all (g);
991 r = guestfs_lvm_remove_all (g);
996 char device[] = "/dev/sda";
998 char lines_0[] = ",";
1005 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1010 char fstype[] = "ext2";
1011 char device[] = "/dev/sda1";
1012 device[5] = devchar;
1015 r = guestfs_mkfs (g, fstype, device);
1020 char device[] = "/dev/sda1";
1021 device[5] = devchar;
1022 char mountpoint[] = "/";
1025 r = guestfs_mount (g, device, mountpoint);
1029 /* TestOutputList for strings_e (0) */
1031 char path[] = "/new";
1032 char content[] = "hello\nworld\n";
1035 r = guestfs_write_file (g, path, content, 0);
1040 char encoding[] = "b";
1041 char path[] = "/new";
1045 r = guestfs_strings_e (g, encoding, path);
1049 fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
1053 for (i = 0; r[i] != NULL; ++i)
1060 static int test_strings_e_1_skip (void)
1064 str = getenv ("SKIP_TEST_STRINGS_E_1");
1065 if (str && strcmp (str, "1") == 0) return 1;
1066 str = getenv ("SKIP_TEST_STRINGS_E");
1067 if (str && strcmp (str, "1") == 0) return 1;
1071 static int test_strings_e_1 (void)
1073 if (test_strings_e_1_skip ()) {
1074 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_1");
1078 printf ("%s skipped (reason: test disabled in generator)\n", "test_strings_e_1");
1082 static int test_strings_0_skip (void)
1086 str = getenv ("SKIP_TEST_STRINGS_0");
1087 if (str && strcmp (str, "1") == 0) return 1;
1088 str = getenv ("SKIP_TEST_STRINGS");
1089 if (str && strcmp (str, "1") == 0) return 1;
1093 static int test_strings_0 (void)
1095 if (test_strings_0_skip ()) {
1096 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_0");
1100 /* InitBasicFS for test_strings_0: create ext2 on /dev/sda1 */
1102 char device[] = "/dev/sda";
1103 device[5] = devchar;
1106 r = guestfs_blockdev_setrw (g, device);
1113 r = guestfs_umount_all (g);
1120 r = guestfs_lvm_remove_all (g);
1125 char device[] = "/dev/sda";
1126 device[5] = devchar;
1127 char lines_0[] = ",";
1134 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1139 char fstype[] = "ext2";
1140 char device[] = "/dev/sda1";
1141 device[5] = devchar;
1144 r = guestfs_mkfs (g, fstype, device);
1149 char device[] = "/dev/sda1";
1150 device[5] = devchar;
1151 char mountpoint[] = "/";
1154 r = guestfs_mount (g, device, mountpoint);
1158 /* TestOutputList for strings (0) */
1160 char path[] = "/new";
1161 char content[] = "hello\nworld\n";
1164 r = guestfs_write_file (g, path, content, 0);
1169 char path[] = "/new";
1173 r = guestfs_strings (g, path);
1177 fprintf (stderr, "test_strings_0: short list returned from command\n");
1182 char expected[] = "hello";
1183 if (strcmp (r[0], expected) != 0) {
1184 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
1189 fprintf (stderr, "test_strings_0: short list returned from command\n");
1194 char expected[] = "world";
1195 if (strcmp (r[1], expected) != 0) {
1196 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
1201 fprintf (stderr, "test_strings_0: extra elements returned from command\n");
1205 for (i = 0; r[i] != NULL; ++i)
1212 static int test_strings_1_skip (void)
1216 str = getenv ("SKIP_TEST_STRINGS_1");
1217 if (str && strcmp (str, "1") == 0) return 1;
1218 str = getenv ("SKIP_TEST_STRINGS");
1219 if (str && strcmp (str, "1") == 0) return 1;
1223 static int test_strings_1 (void)
1225 if (test_strings_1_skip ()) {
1226 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_1");
1230 /* InitBasicFS for test_strings_1: create ext2 on /dev/sda1 */
1232 char device[] = "/dev/sda";
1233 device[5] = devchar;
1236 r = guestfs_blockdev_setrw (g, device);
1243 r = guestfs_umount_all (g);
1250 r = guestfs_lvm_remove_all (g);
1255 char device[] = "/dev/sda";
1256 device[5] = devchar;
1257 char lines_0[] = ",";
1264 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1269 char fstype[] = "ext2";
1270 char device[] = "/dev/sda1";
1271 device[5] = devchar;
1274 r = guestfs_mkfs (g, fstype, device);
1279 char device[] = "/dev/sda1";
1280 device[5] = devchar;
1281 char mountpoint[] = "/";
1284 r = guestfs_mount (g, device, mountpoint);
1288 /* TestOutputList for strings (1) */
1290 char path[] = "/new";
1293 r = guestfs_touch (g, path);
1298 char path[] = "/new";
1302 r = guestfs_strings (g, path);
1306 fprintf (stderr, "test_strings_1: extra elements returned from command\n");
1310 for (i = 0; r[i] != NULL; ++i)
1317 static int test_equal_0_skip (void)
1321 str = getenv ("SKIP_TEST_EQUAL_0");
1322 if (str && strcmp (str, "1") == 0) return 1;
1323 str = getenv ("SKIP_TEST_EQUAL");
1324 if (str && strcmp (str, "1") == 0) return 1;
1328 static int test_equal_0 (void)
1330 if (test_equal_0_skip ()) {
1331 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_0");
1335 /* InitBasicFS for test_equal_0: create ext2 on /dev/sda1 */
1337 char device[] = "/dev/sda";
1338 device[5] = devchar;
1341 r = guestfs_blockdev_setrw (g, device);
1348 r = guestfs_umount_all (g);
1355 r = guestfs_lvm_remove_all (g);
1360 char device[] = "/dev/sda";
1361 device[5] = devchar;
1362 char lines_0[] = ",";
1369 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1374 char fstype[] = "ext2";
1375 char device[] = "/dev/sda1";
1376 device[5] = devchar;
1379 r = guestfs_mkfs (g, fstype, device);
1384 char device[] = "/dev/sda1";
1385 device[5] = devchar;
1386 char mountpoint[] = "/";
1389 r = guestfs_mount (g, device, mountpoint);
1393 /* TestOutputTrue for equal (0) */
1395 char path[] = "/file1";
1396 char content[] = "contents of a file";
1399 r = guestfs_write_file (g, path, content, 0);
1404 char src[] = "/file1";
1405 char dest[] = "/file2";
1408 r = guestfs_cp (g, src, dest);
1413 char file1[] = "/file1";
1414 char file2[] = "/file2";
1417 r = guestfs_equal (g, file1, file2);
1421 fprintf (stderr, "test_equal_0: expected true, got false\n");
1428 static int test_equal_1_skip (void)
1432 str = getenv ("SKIP_TEST_EQUAL_1");
1433 if (str && strcmp (str, "1") == 0) return 1;
1434 str = getenv ("SKIP_TEST_EQUAL");
1435 if (str && strcmp (str, "1") == 0) return 1;
1439 static int test_equal_1 (void)
1441 if (test_equal_1_skip ()) {
1442 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_1");
1446 /* InitBasicFS for test_equal_1: create ext2 on /dev/sda1 */
1448 char device[] = "/dev/sda";
1449 device[5] = devchar;
1452 r = guestfs_blockdev_setrw (g, device);
1459 r = guestfs_umount_all (g);
1466 r = guestfs_lvm_remove_all (g);
1471 char device[] = "/dev/sda";
1472 device[5] = devchar;
1473 char lines_0[] = ",";
1480 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1485 char fstype[] = "ext2";
1486 char device[] = "/dev/sda1";
1487 device[5] = devchar;
1490 r = guestfs_mkfs (g, fstype, device);
1495 char device[] = "/dev/sda1";
1496 device[5] = devchar;
1497 char mountpoint[] = "/";
1500 r = guestfs_mount (g, device, mountpoint);
1504 /* TestOutputFalse for equal (1) */
1506 char path[] = "/file1";
1507 char content[] = "contents of a file";
1510 r = guestfs_write_file (g, path, content, 0);
1515 char path[] = "/file2";
1516 char content[] = "contents of another file";
1519 r = guestfs_write_file (g, path, content, 0);
1524 char file1[] = "/file1";
1525 char file2[] = "/file2";
1528 r = guestfs_equal (g, file1, file2);
1532 fprintf (stderr, "test_equal_1: expected false, got true\n");
1539 static int test_equal_2_skip (void)
1543 str = getenv ("SKIP_TEST_EQUAL_2");
1544 if (str && strcmp (str, "1") == 0) return 1;
1545 str = getenv ("SKIP_TEST_EQUAL");
1546 if (str && strcmp (str, "1") == 0) return 1;
1550 static int test_equal_2 (void)
1552 if (test_equal_2_skip ()) {
1553 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_2");
1557 /* InitBasicFS for test_equal_2: create ext2 on /dev/sda1 */
1559 char device[] = "/dev/sda";
1560 device[5] = devchar;
1563 r = guestfs_blockdev_setrw (g, device);
1570 r = guestfs_umount_all (g);
1577 r = guestfs_lvm_remove_all (g);
1582 char device[] = "/dev/sda";
1583 device[5] = devchar;
1584 char lines_0[] = ",";
1591 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1596 char fstype[] = "ext2";
1597 char device[] = "/dev/sda1";
1598 device[5] = devchar;
1601 r = guestfs_mkfs (g, fstype, device);
1606 char device[] = "/dev/sda1";
1607 device[5] = devchar;
1608 char mountpoint[] = "/";
1611 r = guestfs_mount (g, device, mountpoint);
1615 /* TestLastFail for equal (2) */
1617 char file1[] = "/file1";
1618 char file2[] = "/file2";
1621 r = guestfs_equal (g, file1, file2);
1628 static int test_ping_daemon_0_skip (void)
1632 str = getenv ("SKIP_TEST_PING_DAEMON_0");
1633 if (str && strcmp (str, "1") == 0) return 1;
1634 str = getenv ("SKIP_TEST_PING_DAEMON");
1635 if (str && strcmp (str, "1") == 0) return 1;
1639 static int test_ping_daemon_0 (void)
1641 if (test_ping_daemon_0_skip ()) {
1642 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ping_daemon_0");
1646 /* InitNone|InitEmpty for test_ping_daemon_0 */
1648 char device[] = "/dev/sda";
1649 device[5] = devchar;
1652 r = guestfs_blockdev_setrw (g, device);
1659 r = guestfs_umount_all (g);
1666 r = guestfs_lvm_remove_all (g);
1670 /* TestRun for ping_daemon (0) */
1674 r = guestfs_ping_daemon (g);
1681 static int test_dmesg_0_skip (void)
1685 str = getenv ("SKIP_TEST_DMESG_0");
1686 if (str && strcmp (str, "1") == 0) return 1;
1687 str = getenv ("SKIP_TEST_DMESG");
1688 if (str && strcmp (str, "1") == 0) return 1;
1692 static int test_dmesg_0 (void)
1694 if (test_dmesg_0_skip ()) {
1695 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_dmesg_0");
1699 /* InitNone|InitEmpty for test_dmesg_0 */
1701 char device[] = "/dev/sda";
1702 device[5] = devchar;
1705 r = guestfs_blockdev_setrw (g, device);
1712 r = guestfs_umount_all (g);
1719 r = guestfs_lvm_remove_all (g);
1723 /* TestRun for dmesg (0) */
1727 r = guestfs_dmesg (g);
1735 static int test_drop_caches_0_skip (void)
1739 str = getenv ("SKIP_TEST_DROP_CACHES_0");
1740 if (str && strcmp (str, "1") == 0) return 1;
1741 str = getenv ("SKIP_TEST_DROP_CACHES");
1742 if (str && strcmp (str, "1") == 0) return 1;
1746 static int test_drop_caches_0 (void)
1748 if (test_drop_caches_0_skip ()) {
1749 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_drop_caches_0");
1753 /* InitNone|InitEmpty for test_drop_caches_0 */
1755 char device[] = "/dev/sda";
1756 device[5] = devchar;
1759 r = guestfs_blockdev_setrw (g, device);
1766 r = guestfs_umount_all (g);
1773 r = guestfs_lvm_remove_all (g);
1777 /* TestRun for drop_caches (0) */
1781 r = guestfs_drop_caches (g, 3);
1788 static int test_mv_0_skip (void)
1792 str = getenv ("SKIP_TEST_MV_0");
1793 if (str && strcmp (str, "1") == 0) return 1;
1794 str = getenv ("SKIP_TEST_MV");
1795 if (str && strcmp (str, "1") == 0) return 1;
1799 static int test_mv_0 (void)
1801 if (test_mv_0_skip ()) {
1802 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_0");
1806 /* InitBasicFS for test_mv_0: create ext2 on /dev/sda1 */
1808 char device[] = "/dev/sda";
1809 device[5] = devchar;
1812 r = guestfs_blockdev_setrw (g, device);
1819 r = guestfs_umount_all (g);
1826 r = guestfs_lvm_remove_all (g);
1831 char device[] = "/dev/sda";
1832 device[5] = devchar;
1833 char lines_0[] = ",";
1840 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1845 char fstype[] = "ext2";
1846 char device[] = "/dev/sda1";
1847 device[5] = devchar;
1850 r = guestfs_mkfs (g, fstype, device);
1855 char device[] = "/dev/sda1";
1856 device[5] = devchar;
1857 char mountpoint[] = "/";
1860 r = guestfs_mount (g, device, mountpoint);
1864 /* TestOutput for mv (0) */
1865 char expected[] = "file content";
1867 char path[] = "/old";
1868 char content[] = "file content";
1871 r = guestfs_write_file (g, path, content, 0);
1876 char src[] = "/old";
1877 char dest[] = "/new";
1880 r = guestfs_mv (g, src, dest);
1885 char path[] = "/new";
1888 r = guestfs_cat (g, path);
1891 if (strcmp (r, expected) != 0) {
1892 fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
1900 static int test_mv_1_skip (void)
1904 str = getenv ("SKIP_TEST_MV_1");
1905 if (str && strcmp (str, "1") == 0) return 1;
1906 str = getenv ("SKIP_TEST_MV");
1907 if (str && strcmp (str, "1") == 0) return 1;
1911 static int test_mv_1 (void)
1913 if (test_mv_1_skip ()) {
1914 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_1");
1918 /* InitBasicFS for test_mv_1: create ext2 on /dev/sda1 */
1920 char device[] = "/dev/sda";
1921 device[5] = devchar;
1924 r = guestfs_blockdev_setrw (g, device);
1931 r = guestfs_umount_all (g);
1938 r = guestfs_lvm_remove_all (g);
1943 char device[] = "/dev/sda";
1944 device[5] = devchar;
1945 char lines_0[] = ",";
1952 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1957 char fstype[] = "ext2";
1958 char device[] = "/dev/sda1";
1959 device[5] = devchar;
1962 r = guestfs_mkfs (g, fstype, device);
1967 char device[] = "/dev/sda1";
1968 device[5] = devchar;
1969 char mountpoint[] = "/";
1972 r = guestfs_mount (g, device, mountpoint);
1976 /* TestOutputFalse for mv (1) */
1978 char path[] = "/old";
1979 char content[] = "file content";
1982 r = guestfs_write_file (g, path, content, 0);
1987 char src[] = "/old";
1988 char dest[] = "/new";
1991 r = guestfs_mv (g, src, dest);
1996 char path[] = "/old";
1999 r = guestfs_is_file (g, path);
2003 fprintf (stderr, "test_mv_1: expected false, got true\n");
2010 static int test_cp_a_0_skip (void)
2014 str = getenv ("SKIP_TEST_CP_A_0");
2015 if (str && strcmp (str, "1") == 0) return 1;
2016 str = getenv ("SKIP_TEST_CP_A");
2017 if (str && strcmp (str, "1") == 0) return 1;
2021 static int test_cp_a_0 (void)
2023 if (test_cp_a_0_skip ()) {
2024 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_a_0");
2028 /* InitBasicFS for test_cp_a_0: create ext2 on /dev/sda1 */
2030 char device[] = "/dev/sda";
2031 device[5] = devchar;
2034 r = guestfs_blockdev_setrw (g, device);
2041 r = guestfs_umount_all (g);
2048 r = guestfs_lvm_remove_all (g);
2053 char device[] = "/dev/sda";
2054 device[5] = devchar;
2055 char lines_0[] = ",";
2062 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2067 char fstype[] = "ext2";
2068 char device[] = "/dev/sda1";
2069 device[5] = devchar;
2072 r = guestfs_mkfs (g, fstype, device);
2077 char device[] = "/dev/sda1";
2078 device[5] = devchar;
2079 char mountpoint[] = "/";
2082 r = guestfs_mount (g, device, mountpoint);
2086 /* TestOutput for cp_a (0) */
2087 char expected[] = "file content";
2089 char path[] = "/olddir";
2092 r = guestfs_mkdir (g, path);
2097 char path[] = "/newdir";
2100 r = guestfs_mkdir (g, path);
2105 char path[] = "/olddir/file";
2106 char content[] = "file content";
2109 r = guestfs_write_file (g, path, content, 0);
2114 char src[] = "/olddir";
2115 char dest[] = "/newdir";
2118 r = guestfs_cp_a (g, src, dest);
2123 char path[] = "/newdir/olddir/file";
2126 r = guestfs_cat (g, path);
2129 if (strcmp (r, expected) != 0) {
2130 fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
2138 static int test_cp_0_skip (void)
2142 str = getenv ("SKIP_TEST_CP_0");
2143 if (str && strcmp (str, "1") == 0) return 1;
2144 str = getenv ("SKIP_TEST_CP");
2145 if (str && strcmp (str, "1") == 0) return 1;
2149 static int test_cp_0 (void)
2151 if (test_cp_0_skip ()) {
2152 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_0");
2156 /* InitBasicFS for test_cp_0: create ext2 on /dev/sda1 */
2158 char device[] = "/dev/sda";
2159 device[5] = devchar;
2162 r = guestfs_blockdev_setrw (g, device);
2169 r = guestfs_umount_all (g);
2176 r = guestfs_lvm_remove_all (g);
2181 char device[] = "/dev/sda";
2182 device[5] = devchar;
2183 char lines_0[] = ",";
2190 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2195 char fstype[] = "ext2";
2196 char device[] = "/dev/sda1";
2197 device[5] = devchar;
2200 r = guestfs_mkfs (g, fstype, device);
2205 char device[] = "/dev/sda1";
2206 device[5] = devchar;
2207 char mountpoint[] = "/";
2210 r = guestfs_mount (g, device, mountpoint);
2214 /* TestOutput for cp (0) */
2215 char expected[] = "file content";
2217 char path[] = "/old";
2218 char content[] = "file content";
2221 r = guestfs_write_file (g, path, content, 0);
2226 char src[] = "/old";
2227 char dest[] = "/new";
2230 r = guestfs_cp (g, src, dest);
2235 char path[] = "/new";
2238 r = guestfs_cat (g, path);
2241 if (strcmp (r, expected) != 0) {
2242 fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
2250 static int test_cp_1_skip (void)
2254 str = getenv ("SKIP_TEST_CP_1");
2255 if (str && strcmp (str, "1") == 0) return 1;
2256 str = getenv ("SKIP_TEST_CP");
2257 if (str && strcmp (str, "1") == 0) return 1;
2261 static int test_cp_1 (void)
2263 if (test_cp_1_skip ()) {
2264 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_1");
2268 /* InitBasicFS for test_cp_1: create ext2 on /dev/sda1 */
2270 char device[] = "/dev/sda";
2271 device[5] = devchar;
2274 r = guestfs_blockdev_setrw (g, device);
2281 r = guestfs_umount_all (g);
2288 r = guestfs_lvm_remove_all (g);
2293 char device[] = "/dev/sda";
2294 device[5] = devchar;
2295 char lines_0[] = ",";
2302 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2307 char fstype[] = "ext2";
2308 char device[] = "/dev/sda1";
2309 device[5] = devchar;
2312 r = guestfs_mkfs (g, fstype, device);
2317 char device[] = "/dev/sda1";
2318 device[5] = devchar;
2319 char mountpoint[] = "/";
2322 r = guestfs_mount (g, device, mountpoint);
2326 /* TestOutputTrue for cp (1) */
2328 char path[] = "/old";
2329 char content[] = "file content";
2332 r = guestfs_write_file (g, path, content, 0);
2337 char src[] = "/old";
2338 char dest[] = "/new";
2341 r = guestfs_cp (g, src, dest);
2346 char path[] = "/old";
2349 r = guestfs_is_file (g, path);
2353 fprintf (stderr, "test_cp_1: expected true, got false\n");
2360 static int test_cp_2_skip (void)
2364 str = getenv ("SKIP_TEST_CP_2");
2365 if (str && strcmp (str, "1") == 0) return 1;
2366 str = getenv ("SKIP_TEST_CP");
2367 if (str && strcmp (str, "1") == 0) return 1;
2371 static int test_cp_2 (void)
2373 if (test_cp_2_skip ()) {
2374 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_2");
2378 /* InitBasicFS for test_cp_2: create ext2 on /dev/sda1 */
2380 char device[] = "/dev/sda";
2381 device[5] = devchar;
2384 r = guestfs_blockdev_setrw (g, device);
2391 r = guestfs_umount_all (g);
2398 r = guestfs_lvm_remove_all (g);
2403 char device[] = "/dev/sda";
2404 device[5] = devchar;
2405 char lines_0[] = ",";
2412 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2417 char fstype[] = "ext2";
2418 char device[] = "/dev/sda1";
2419 device[5] = devchar;
2422 r = guestfs_mkfs (g, fstype, device);
2427 char device[] = "/dev/sda1";
2428 device[5] = devchar;
2429 char mountpoint[] = "/";
2432 r = guestfs_mount (g, device, mountpoint);
2436 /* TestOutput for cp (2) */
2437 char expected[] = "file content";
2439 char path[] = "/old";
2440 char content[] = "file content";
2443 r = guestfs_write_file (g, path, content, 0);
2448 char path[] = "/dir";
2451 r = guestfs_mkdir (g, path);
2456 char src[] = "/old";
2457 char dest[] = "/dir/new";
2460 r = guestfs_cp (g, src, dest);
2465 char path[] = "/dir/new";
2468 r = guestfs_cat (g, path);
2471 if (strcmp (r, expected) != 0) {
2472 fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
2480 static int test_grub_install_0_skip (void)
2484 str = getenv ("SKIP_TEST_GRUB_INSTALL_0");
2485 if (str && strcmp (str, "1") == 0) return 1;
2486 str = getenv ("SKIP_TEST_GRUB_INSTALL");
2487 if (str && strcmp (str, "1") == 0) return 1;
2491 static int test_grub_install_0 (void)
2493 if (test_grub_install_0_skip ()) {
2494 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_grub_install_0");
2498 /* InitBasicFS for test_grub_install_0: create ext2 on /dev/sda1 */
2500 char device[] = "/dev/sda";
2501 device[5] = devchar;
2504 r = guestfs_blockdev_setrw (g, device);
2511 r = guestfs_umount_all (g);
2518 r = guestfs_lvm_remove_all (g);
2523 char device[] = "/dev/sda";
2524 device[5] = devchar;
2525 char lines_0[] = ",";
2532 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2537 char fstype[] = "ext2";
2538 char device[] = "/dev/sda1";
2539 device[5] = devchar;
2542 r = guestfs_mkfs (g, fstype, device);
2547 char device[] = "/dev/sda1";
2548 device[5] = devchar;
2549 char mountpoint[] = "/";
2552 r = guestfs_mount (g, device, mountpoint);
2556 /* TestOutputTrue for grub_install (0) */
2559 char device[] = "/dev/sda1";
2560 device[5] = devchar;
2563 r = guestfs_grub_install (g, root, device);
2568 char path[] = "/boot";
2571 r = guestfs_is_dir (g, path);
2575 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
2582 static int test_zero_0_skip (void)
2586 str = getenv ("SKIP_TEST_ZERO_0");
2587 if (str && strcmp (str, "1") == 0) return 1;
2588 str = getenv ("SKIP_TEST_ZERO");
2589 if (str && strcmp (str, "1") == 0) return 1;
2593 static int test_zero_0 (void)
2595 if (test_zero_0_skip ()) {
2596 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zero_0");
2600 /* InitBasicFS for test_zero_0: create ext2 on /dev/sda1 */
2602 char device[] = "/dev/sda";
2603 device[5] = devchar;
2606 r = guestfs_blockdev_setrw (g, device);
2613 r = guestfs_umount_all (g);
2620 r = guestfs_lvm_remove_all (g);
2625 char device[] = "/dev/sda";
2626 device[5] = devchar;
2627 char lines_0[] = ",";
2634 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2639 char fstype[] = "ext2";
2640 char device[] = "/dev/sda1";
2641 device[5] = devchar;
2644 r = guestfs_mkfs (g, fstype, device);
2649 char device[] = "/dev/sda1";
2650 device[5] = devchar;
2651 char mountpoint[] = "/";
2654 r = guestfs_mount (g, device, mountpoint);
2658 /* TestOutput for zero (0) */
2659 char expected[] = "data";
2661 char pathordevice[] = "/dev/sda1";
2662 pathordevice[5] = devchar;
2665 r = guestfs_umount (g, pathordevice);
2670 char device[] = "/dev/sda1";
2671 device[5] = devchar;
2674 r = guestfs_zero (g, device);
2679 char path[] = "/dev/sda1";
2683 r = guestfs_file (g, path);
2686 if (strcmp (r, expected) != 0) {
2687 fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
2695 static int test_fsck_0_skip (void)
2699 str = getenv ("SKIP_TEST_FSCK_0");
2700 if (str && strcmp (str, "1") == 0) return 1;
2701 str = getenv ("SKIP_TEST_FSCK");
2702 if (str && strcmp (str, "1") == 0) return 1;
2706 static int test_fsck_0 (void)
2708 if (test_fsck_0_skip ()) {
2709 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_0");
2713 /* InitBasicFS for test_fsck_0: create ext2 on /dev/sda1 */
2715 char device[] = "/dev/sda";
2716 device[5] = devchar;
2719 r = guestfs_blockdev_setrw (g, device);
2726 r = guestfs_umount_all (g);
2733 r = guestfs_lvm_remove_all (g);
2738 char device[] = "/dev/sda";
2739 device[5] = devchar;
2740 char lines_0[] = ",";
2747 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2752 char fstype[] = "ext2";
2753 char device[] = "/dev/sda1";
2754 device[5] = devchar;
2757 r = guestfs_mkfs (g, fstype, device);
2762 char device[] = "/dev/sda1";
2763 device[5] = devchar;
2764 char mountpoint[] = "/";
2767 r = guestfs_mount (g, device, mountpoint);
2771 /* TestOutputInt for fsck (0) */
2773 char pathordevice[] = "/dev/sda1";
2774 pathordevice[5] = devchar;
2777 r = guestfs_umount (g, pathordevice);
2782 char fstype[] = "ext2";
2783 char device[] = "/dev/sda1";
2784 device[5] = devchar;
2787 r = guestfs_fsck (g, fstype, device);
2791 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
2798 static int test_fsck_1_skip (void)
2802 str = getenv ("SKIP_TEST_FSCK_1");
2803 if (str && strcmp (str, "1") == 0) return 1;
2804 str = getenv ("SKIP_TEST_FSCK");
2805 if (str && strcmp (str, "1") == 0) return 1;
2809 static int test_fsck_1 (void)
2811 if (test_fsck_1_skip ()) {
2812 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_1");
2816 /* InitBasicFS for test_fsck_1: create ext2 on /dev/sda1 */
2818 char device[] = "/dev/sda";
2819 device[5] = devchar;
2822 r = guestfs_blockdev_setrw (g, device);
2829 r = guestfs_umount_all (g);
2836 r = guestfs_lvm_remove_all (g);
2841 char device[] = "/dev/sda";
2842 device[5] = devchar;
2843 char lines_0[] = ",";
2850 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2855 char fstype[] = "ext2";
2856 char device[] = "/dev/sda1";
2857 device[5] = devchar;
2860 r = guestfs_mkfs (g, fstype, device);
2865 char device[] = "/dev/sda1";
2866 device[5] = devchar;
2867 char mountpoint[] = "/";
2870 r = guestfs_mount (g, device, mountpoint);
2874 /* TestOutputInt for fsck (1) */
2876 char pathordevice[] = "/dev/sda1";
2877 pathordevice[5] = devchar;
2880 r = guestfs_umount (g, pathordevice);
2885 char device[] = "/dev/sda1";
2886 device[5] = devchar;
2889 r = guestfs_zero (g, device);
2894 char fstype[] = "ext2";
2895 char device[] = "/dev/sda1";
2896 device[5] = devchar;
2899 r = guestfs_fsck (g, fstype, device);
2903 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
2910 static int test_set_e2uuid_0_skip (void)
2914 str = getenv ("SKIP_TEST_SET_E2UUID_0");
2915 if (str && strcmp (str, "1") == 0) return 1;
2916 str = getenv ("SKIP_TEST_SET_E2UUID");
2917 if (str && strcmp (str, "1") == 0) return 1;
2921 static int test_set_e2uuid_0 (void)
2923 if (test_set_e2uuid_0_skip ()) {
2924 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_0");
2928 /* InitBasicFS for test_set_e2uuid_0: create ext2 on /dev/sda1 */
2930 char device[] = "/dev/sda";
2931 device[5] = devchar;
2934 r = guestfs_blockdev_setrw (g, device);
2941 r = guestfs_umount_all (g);
2948 r = guestfs_lvm_remove_all (g);
2953 char device[] = "/dev/sda";
2954 device[5] = devchar;
2955 char lines_0[] = ",";
2962 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2967 char fstype[] = "ext2";
2968 char device[] = "/dev/sda1";
2969 device[5] = devchar;
2972 r = guestfs_mkfs (g, fstype, device);
2977 char device[] = "/dev/sda1";
2978 device[5] = devchar;
2979 char mountpoint[] = "/";
2982 r = guestfs_mount (g, device, mountpoint);
2986 /* TestOutput for set_e2uuid (0) */
2987 char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
2989 char device[] = "/dev/sda1";
2990 device[5] = devchar;
2991 char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
2994 r = guestfs_set_e2uuid (g, device, uuid);
2999 char device[] = "/dev/sda1";
3000 device[5] = devchar;
3003 r = guestfs_get_e2uuid (g, device);
3006 if (strcmp (r, expected) != 0) {
3007 fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
3015 static int test_set_e2uuid_1_skip (void)
3019 str = getenv ("SKIP_TEST_SET_E2UUID_1");
3020 if (str && strcmp (str, "1") == 0) return 1;
3021 str = getenv ("SKIP_TEST_SET_E2UUID");
3022 if (str && strcmp (str, "1") == 0) return 1;
3026 static int test_set_e2uuid_1 (void)
3028 if (test_set_e2uuid_1_skip ()) {
3029 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_1");
3033 /* InitBasicFS for test_set_e2uuid_1: create ext2 on /dev/sda1 */
3035 char device[] = "/dev/sda";
3036 device[5] = devchar;
3039 r = guestfs_blockdev_setrw (g, device);
3046 r = guestfs_umount_all (g);
3053 r = guestfs_lvm_remove_all (g);
3058 char device[] = "/dev/sda";
3059 device[5] = devchar;
3060 char lines_0[] = ",";
3067 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3072 char fstype[] = "ext2";
3073 char device[] = "/dev/sda1";
3074 device[5] = devchar;
3077 r = guestfs_mkfs (g, fstype, device);
3082 char device[] = "/dev/sda1";
3083 device[5] = devchar;
3084 char mountpoint[] = "/";
3087 r = guestfs_mount (g, device, mountpoint);
3091 /* TestOutput for set_e2uuid (1) */
3092 char expected[] = "";
3094 char device[] = "/dev/sda1";
3095 device[5] = devchar;
3096 char uuid[] = "clear";
3099 r = guestfs_set_e2uuid (g, device, uuid);
3104 char device[] = "/dev/sda1";
3105 device[5] = devchar;
3108 r = guestfs_get_e2uuid (g, device);
3111 if (strcmp (r, expected) != 0) {
3112 fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
3120 static int test_set_e2uuid_2_skip (void)
3124 str = getenv ("SKIP_TEST_SET_E2UUID_2");
3125 if (str && strcmp (str, "1") == 0) return 1;
3126 str = getenv ("SKIP_TEST_SET_E2UUID");
3127 if (str && strcmp (str, "1") == 0) return 1;
3131 static int test_set_e2uuid_2 (void)
3133 if (test_set_e2uuid_2_skip ()) {
3134 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_2");
3138 /* InitBasicFS for test_set_e2uuid_2: create ext2 on /dev/sda1 */
3140 char device[] = "/dev/sda";
3141 device[5] = devchar;
3144 r = guestfs_blockdev_setrw (g, device);
3151 r = guestfs_umount_all (g);
3158 r = guestfs_lvm_remove_all (g);
3163 char device[] = "/dev/sda";
3164 device[5] = devchar;
3165 char lines_0[] = ",";
3172 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3177 char fstype[] = "ext2";
3178 char device[] = "/dev/sda1";
3179 device[5] = devchar;
3182 r = guestfs_mkfs (g, fstype, device);
3187 char device[] = "/dev/sda1";
3188 device[5] = devchar;
3189 char mountpoint[] = "/";
3192 r = guestfs_mount (g, device, mountpoint);
3196 /* TestRun for set_e2uuid (2) */
3198 char device[] = "/dev/sda1";
3199 device[5] = devchar;
3200 char uuid[] = "random";
3203 r = guestfs_set_e2uuid (g, device, uuid);
3210 static int test_set_e2uuid_3_skip (void)
3214 str = getenv ("SKIP_TEST_SET_E2UUID_3");
3215 if (str && strcmp (str, "1") == 0) return 1;
3216 str = getenv ("SKIP_TEST_SET_E2UUID");
3217 if (str && strcmp (str, "1") == 0) return 1;
3221 static int test_set_e2uuid_3 (void)
3223 if (test_set_e2uuid_3_skip ()) {
3224 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_3");
3228 /* InitBasicFS for test_set_e2uuid_3: create ext2 on /dev/sda1 */
3230 char device[] = "/dev/sda";
3231 device[5] = devchar;
3234 r = guestfs_blockdev_setrw (g, device);
3241 r = guestfs_umount_all (g);
3248 r = guestfs_lvm_remove_all (g);
3253 char device[] = "/dev/sda";
3254 device[5] = devchar;
3255 char lines_0[] = ",";
3262 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3267 char fstype[] = "ext2";
3268 char device[] = "/dev/sda1";
3269 device[5] = devchar;
3272 r = guestfs_mkfs (g, fstype, device);
3277 char device[] = "/dev/sda1";
3278 device[5] = devchar;
3279 char mountpoint[] = "/";
3282 r = guestfs_mount (g, device, mountpoint);
3286 /* TestRun for set_e2uuid (3) */
3288 char device[] = "/dev/sda1";
3289 device[5] = devchar;
3290 char uuid[] = "time";
3293 r = guestfs_set_e2uuid (g, device, uuid);
3300 static int test_set_e2label_0_skip (void)
3304 str = getenv ("SKIP_TEST_SET_E2LABEL_0");
3305 if (str && strcmp (str, "1") == 0) return 1;
3306 str = getenv ("SKIP_TEST_SET_E2LABEL");
3307 if (str && strcmp (str, "1") == 0) return 1;
3311 static int test_set_e2label_0 (void)
3313 if (test_set_e2label_0_skip ()) {
3314 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2label_0");
3318 /* InitBasicFS for test_set_e2label_0: create ext2 on /dev/sda1 */
3320 char device[] = "/dev/sda";
3321 device[5] = devchar;
3324 r = guestfs_blockdev_setrw (g, device);
3331 r = guestfs_umount_all (g);
3338 r = guestfs_lvm_remove_all (g);
3343 char device[] = "/dev/sda";
3344 device[5] = devchar;
3345 char lines_0[] = ",";
3352 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3357 char fstype[] = "ext2";
3358 char device[] = "/dev/sda1";
3359 device[5] = devchar;
3362 r = guestfs_mkfs (g, fstype, device);
3367 char device[] = "/dev/sda1";
3368 device[5] = devchar;
3369 char mountpoint[] = "/";
3372 r = guestfs_mount (g, device, mountpoint);
3376 /* TestOutput for set_e2label (0) */
3377 char expected[] = "testlabel";
3379 char device[] = "/dev/sda1";
3380 device[5] = devchar;
3381 char label[] = "testlabel";
3384 r = guestfs_set_e2label (g, device, label);
3389 char device[] = "/dev/sda1";
3390 device[5] = devchar;
3393 r = guestfs_get_e2label (g, device);
3396 if (strcmp (r, expected) != 0) {
3397 fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
3405 static int test_pvremove_0_skip (void)
3409 str = getenv ("SKIP_TEST_PVREMOVE_0");
3410 if (str && strcmp (str, "1") == 0) return 1;
3411 str = getenv ("SKIP_TEST_PVREMOVE");
3412 if (str && strcmp (str, "1") == 0) return 1;
3416 static int test_pvremove_0 (void)
3418 if (test_pvremove_0_skip ()) {
3419 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_0");
3423 /* InitNone|InitEmpty for test_pvremove_0 */
3425 char device[] = "/dev/sda";
3426 device[5] = devchar;
3429 r = guestfs_blockdev_setrw (g, device);
3436 r = guestfs_umount_all (g);
3443 r = guestfs_lvm_remove_all (g);
3447 /* TestOutputList for pvremove (0) */
3449 char device[] = "/dev/sda";
3450 device[5] = devchar;
3451 char lines_0[] = ",";
3458 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3463 char device[] = "/dev/sda1";
3464 device[5] = devchar;
3467 r = guestfs_pvcreate (g, device);
3472 char volgroup[] = "VG";
3473 char physvols_0[] = "/dev/sda1";
3474 physvols_0[5] = devchar;
3475 char *physvols[] = {
3481 r = guestfs_vgcreate (g, volgroup, physvols);
3486 char logvol[] = "LV1";
3487 char volgroup[] = "VG";
3490 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3495 char logvol[] = "LV2";
3496 char volgroup[] = "VG";
3499 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3504 char vgname[] = "VG";
3507 r = guestfs_vgremove (g, vgname);
3512 char device[] = "/dev/sda1";
3513 device[5] = devchar;
3516 r = guestfs_pvremove (g, device);
3524 r = guestfs_lvs (g);
3528 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
3532 for (i = 0; r[i] != NULL; ++i)
3539 static int test_pvremove_1_skip (void)
3543 str = getenv ("SKIP_TEST_PVREMOVE_1");
3544 if (str && strcmp (str, "1") == 0) return 1;
3545 str = getenv ("SKIP_TEST_PVREMOVE");
3546 if (str && strcmp (str, "1") == 0) return 1;
3550 static int test_pvremove_1 (void)
3552 if (test_pvremove_1_skip ()) {
3553 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_1");
3557 /* InitNone|InitEmpty for test_pvremove_1 */
3559 char device[] = "/dev/sda";
3560 device[5] = devchar;
3563 r = guestfs_blockdev_setrw (g, device);
3570 r = guestfs_umount_all (g);
3577 r = guestfs_lvm_remove_all (g);
3581 /* TestOutputList for pvremove (1) */
3583 char device[] = "/dev/sda";
3584 device[5] = devchar;
3585 char lines_0[] = ",";
3592 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3597 char device[] = "/dev/sda1";
3598 device[5] = devchar;
3601 r = guestfs_pvcreate (g, device);
3606 char volgroup[] = "VG";
3607 char physvols_0[] = "/dev/sda1";
3608 physvols_0[5] = devchar;
3609 char *physvols[] = {
3615 r = guestfs_vgcreate (g, volgroup, physvols);
3620 char logvol[] = "LV1";
3621 char volgroup[] = "VG";
3624 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3629 char logvol[] = "LV2";
3630 char volgroup[] = "VG";
3633 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3638 char vgname[] = "VG";
3641 r = guestfs_vgremove (g, vgname);
3646 char device[] = "/dev/sda1";
3647 device[5] = devchar;
3650 r = guestfs_pvremove (g, device);
3658 r = guestfs_vgs (g);
3662 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
3666 for (i = 0; r[i] != NULL; ++i)
3673 static int test_pvremove_2_skip (void)
3677 str = getenv ("SKIP_TEST_PVREMOVE_2");
3678 if (str && strcmp (str, "1") == 0) return 1;
3679 str = getenv ("SKIP_TEST_PVREMOVE");
3680 if (str && strcmp (str, "1") == 0) return 1;
3684 static int test_pvremove_2 (void)
3686 if (test_pvremove_2_skip ()) {
3687 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_2");
3691 /* InitNone|InitEmpty for test_pvremove_2 */
3693 char device[] = "/dev/sda";
3694 device[5] = devchar;
3697 r = guestfs_blockdev_setrw (g, device);
3704 r = guestfs_umount_all (g);
3711 r = guestfs_lvm_remove_all (g);
3715 /* TestOutputList for pvremove (2) */
3717 char device[] = "/dev/sda";
3718 device[5] = devchar;
3719 char lines_0[] = ",";
3726 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3731 char device[] = "/dev/sda1";
3732 device[5] = devchar;
3735 r = guestfs_pvcreate (g, device);
3740 char volgroup[] = "VG";
3741 char physvols_0[] = "/dev/sda1";
3742 physvols_0[5] = devchar;
3743 char *physvols[] = {
3749 r = guestfs_vgcreate (g, volgroup, physvols);
3754 char logvol[] = "LV1";
3755 char volgroup[] = "VG";
3758 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3763 char logvol[] = "LV2";
3764 char volgroup[] = "VG";
3767 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3772 char vgname[] = "VG";
3775 r = guestfs_vgremove (g, vgname);
3780 char device[] = "/dev/sda1";
3781 device[5] = devchar;
3784 r = guestfs_pvremove (g, device);
3792 r = guestfs_pvs (g);
3796 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
3800 for (i = 0; r[i] != NULL; ++i)
3807 static int test_vgremove_0_skip (void)
3811 str = getenv ("SKIP_TEST_VGREMOVE_0");
3812 if (str && strcmp (str, "1") == 0) return 1;
3813 str = getenv ("SKIP_TEST_VGREMOVE");
3814 if (str && strcmp (str, "1") == 0) return 1;
3818 static int test_vgremove_0 (void)
3820 if (test_vgremove_0_skip ()) {
3821 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_0");
3825 /* InitNone|InitEmpty for test_vgremove_0 */
3827 char device[] = "/dev/sda";
3828 device[5] = devchar;
3831 r = guestfs_blockdev_setrw (g, device);
3838 r = guestfs_umount_all (g);
3845 r = guestfs_lvm_remove_all (g);
3849 /* TestOutputList for vgremove (0) */
3851 char device[] = "/dev/sda";
3852 device[5] = devchar;
3853 char lines_0[] = ",";
3860 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3865 char device[] = "/dev/sda1";
3866 device[5] = devchar;
3869 r = guestfs_pvcreate (g, device);
3874 char volgroup[] = "VG";
3875 char physvols_0[] = "/dev/sda1";
3876 physvols_0[5] = devchar;
3877 char *physvols[] = {
3883 r = guestfs_vgcreate (g, volgroup, physvols);
3888 char logvol[] = "LV1";
3889 char volgroup[] = "VG";
3892 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3897 char logvol[] = "LV2";
3898 char volgroup[] = "VG";
3901 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3906 char vgname[] = "VG";
3909 r = guestfs_vgremove (g, vgname);
3917 r = guestfs_lvs (g);
3921 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
3925 for (i = 0; r[i] != NULL; ++i)
3932 static int test_vgremove_1_skip (void)
3936 str = getenv ("SKIP_TEST_VGREMOVE_1");
3937 if (str && strcmp (str, "1") == 0) return 1;
3938 str = getenv ("SKIP_TEST_VGREMOVE");
3939 if (str && strcmp (str, "1") == 0) return 1;
3943 static int test_vgremove_1 (void)
3945 if (test_vgremove_1_skip ()) {
3946 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_1");
3950 /* InitNone|InitEmpty for test_vgremove_1 */
3952 char device[] = "/dev/sda";
3953 device[5] = devchar;
3956 r = guestfs_blockdev_setrw (g, device);
3963 r = guestfs_umount_all (g);
3970 r = guestfs_lvm_remove_all (g);
3974 /* TestOutputList for vgremove (1) */
3976 char device[] = "/dev/sda";
3977 device[5] = devchar;
3978 char lines_0[] = ",";
3985 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3990 char device[] = "/dev/sda1";
3991 device[5] = devchar;
3994 r = guestfs_pvcreate (g, device);
3999 char volgroup[] = "VG";
4000 char physvols_0[] = "/dev/sda1";
4001 physvols_0[5] = devchar;
4002 char *physvols[] = {
4008 r = guestfs_vgcreate (g, volgroup, physvols);
4013 char logvol[] = "LV1";
4014 char volgroup[] = "VG";
4017 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4022 char logvol[] = "LV2";
4023 char volgroup[] = "VG";
4026 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4031 char vgname[] = "VG";
4034 r = guestfs_vgremove (g, vgname);
4042 r = guestfs_vgs (g);
4046 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
4050 for (i = 0; r[i] != NULL; ++i)
4057 static int test_lvremove_0_skip (void)
4061 str = getenv ("SKIP_TEST_LVREMOVE_0");
4062 if (str && strcmp (str, "1") == 0) return 1;
4063 str = getenv ("SKIP_TEST_LVREMOVE");
4064 if (str && strcmp (str, "1") == 0) return 1;
4068 static int test_lvremove_0 (void)
4070 if (test_lvremove_0_skip ()) {
4071 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_0");
4075 /* InitNone|InitEmpty for test_lvremove_0 */
4077 char device[] = "/dev/sda";
4078 device[5] = devchar;
4081 r = guestfs_blockdev_setrw (g, device);
4088 r = guestfs_umount_all (g);
4095 r = guestfs_lvm_remove_all (g);
4099 /* TestOutputList for lvremove (0) */
4101 char device[] = "/dev/sda";
4102 device[5] = devchar;
4103 char lines_0[] = ",";
4110 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4115 char device[] = "/dev/sda1";
4116 device[5] = devchar;
4119 r = guestfs_pvcreate (g, device);
4124 char volgroup[] = "VG";
4125 char physvols_0[] = "/dev/sda1";
4126 physvols_0[5] = devchar;
4127 char *physvols[] = {
4133 r = guestfs_vgcreate (g, volgroup, physvols);
4138 char logvol[] = "LV1";
4139 char volgroup[] = "VG";
4142 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4147 char logvol[] = "LV2";
4148 char volgroup[] = "VG";
4151 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4156 char device[] = "/dev/VG/LV1";
4159 r = guestfs_lvremove (g, device);
4167 r = guestfs_lvs (g);
4171 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
4176 char expected[] = "/dev/VG/LV2";
4177 if (strcmp (r[0], expected) != 0) {
4178 fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
4183 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
4187 for (i = 0; r[i] != NULL; ++i)
4194 static int test_lvremove_1_skip (void)
4198 str = getenv ("SKIP_TEST_LVREMOVE_1");
4199 if (str && strcmp (str, "1") == 0) return 1;
4200 str = getenv ("SKIP_TEST_LVREMOVE");
4201 if (str && strcmp (str, "1") == 0) return 1;
4205 static int test_lvremove_1 (void)
4207 if (test_lvremove_1_skip ()) {
4208 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_1");
4212 /* InitNone|InitEmpty for test_lvremove_1 */
4214 char device[] = "/dev/sda";
4215 device[5] = devchar;
4218 r = guestfs_blockdev_setrw (g, device);
4225 r = guestfs_umount_all (g);
4232 r = guestfs_lvm_remove_all (g);
4236 /* TestOutputList for lvremove (1) */
4238 char device[] = "/dev/sda";
4239 device[5] = devchar;
4240 char lines_0[] = ",";
4247 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4252 char device[] = "/dev/sda1";
4253 device[5] = devchar;
4256 r = guestfs_pvcreate (g, device);
4261 char volgroup[] = "VG";
4262 char physvols_0[] = "/dev/sda1";
4263 physvols_0[5] = devchar;
4264 char *physvols[] = {
4270 r = guestfs_vgcreate (g, volgroup, physvols);
4275 char logvol[] = "LV1";
4276 char volgroup[] = "VG";
4279 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4284 char logvol[] = "LV2";
4285 char volgroup[] = "VG";
4288 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4293 char device[] = "/dev/VG";
4296 r = guestfs_lvremove (g, device);
4304 r = guestfs_lvs (g);
4308 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
4312 for (i = 0; r[i] != NULL; ++i)
4319 static int test_lvremove_2_skip (void)
4323 str = getenv ("SKIP_TEST_LVREMOVE_2");
4324 if (str && strcmp (str, "1") == 0) return 1;
4325 str = getenv ("SKIP_TEST_LVREMOVE");
4326 if (str && strcmp (str, "1") == 0) return 1;
4330 static int test_lvremove_2 (void)
4332 if (test_lvremove_2_skip ()) {
4333 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_2");
4337 /* InitNone|InitEmpty for test_lvremove_2 */
4339 char device[] = "/dev/sda";
4340 device[5] = devchar;
4343 r = guestfs_blockdev_setrw (g, device);
4350 r = guestfs_umount_all (g);
4357 r = guestfs_lvm_remove_all (g);
4361 /* TestOutputList for lvremove (2) */
4363 char device[] = "/dev/sda";
4364 device[5] = devchar;
4365 char lines_0[] = ",";
4372 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4377 char device[] = "/dev/sda1";
4378 device[5] = devchar;
4381 r = guestfs_pvcreate (g, device);
4386 char volgroup[] = "VG";
4387 char physvols_0[] = "/dev/sda1";
4388 physvols_0[5] = devchar;
4389 char *physvols[] = {
4395 r = guestfs_vgcreate (g, volgroup, physvols);
4400 char logvol[] = "LV1";
4401 char volgroup[] = "VG";
4404 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4409 char logvol[] = "LV2";
4410 char volgroup[] = "VG";
4413 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4418 char device[] = "/dev/VG";
4421 r = guestfs_lvremove (g, device);
4429 r = guestfs_vgs (g);
4433 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
4438 char expected[] = "VG";
4439 if (strcmp (r[0], expected) != 0) {
4440 fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
4445 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
4449 for (i = 0; r[i] != NULL; ++i)
4456 static int test_mount_ro_0_skip (void)
4460 str = getenv ("SKIP_TEST_MOUNT_RO_0");
4461 if (str && strcmp (str, "1") == 0) return 1;
4462 str = getenv ("SKIP_TEST_MOUNT_RO");
4463 if (str && strcmp (str, "1") == 0) return 1;
4467 static int test_mount_ro_0 (void)
4469 if (test_mount_ro_0_skip ()) {
4470 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_0");
4474 /* InitBasicFS for test_mount_ro_0: create ext2 on /dev/sda1 */
4476 char device[] = "/dev/sda";
4477 device[5] = devchar;
4480 r = guestfs_blockdev_setrw (g, device);
4487 r = guestfs_umount_all (g);
4494 r = guestfs_lvm_remove_all (g);
4499 char device[] = "/dev/sda";
4500 device[5] = devchar;
4501 char lines_0[] = ",";
4508 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4513 char fstype[] = "ext2";
4514 char device[] = "/dev/sda1";
4515 device[5] = devchar;
4518 r = guestfs_mkfs (g, fstype, device);
4523 char device[] = "/dev/sda1";
4524 device[5] = devchar;
4525 char mountpoint[] = "/";
4528 r = guestfs_mount (g, device, mountpoint);
4532 /* TestLastFail for mount_ro (0) */
4534 char pathordevice[] = "/";
4537 r = guestfs_umount (g, pathordevice);
4542 char device[] = "/dev/sda1";
4543 device[5] = devchar;
4544 char mountpoint[] = "/";
4547 r = guestfs_mount_ro (g, device, mountpoint);
4552 char path[] = "/new";
4555 r = guestfs_touch (g, path);
4562 static int test_mount_ro_1_skip (void)
4566 str = getenv ("SKIP_TEST_MOUNT_RO_1");
4567 if (str && strcmp (str, "1") == 0) return 1;
4568 str = getenv ("SKIP_TEST_MOUNT_RO");
4569 if (str && strcmp (str, "1") == 0) return 1;
4573 static int test_mount_ro_1 (void)
4575 if (test_mount_ro_1_skip ()) {
4576 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_1");
4580 /* InitBasicFS for test_mount_ro_1: create ext2 on /dev/sda1 */
4582 char device[] = "/dev/sda";
4583 device[5] = devchar;
4586 r = guestfs_blockdev_setrw (g, device);
4593 r = guestfs_umount_all (g);
4600 r = guestfs_lvm_remove_all (g);
4605 char device[] = "/dev/sda";
4606 device[5] = devchar;
4607 char lines_0[] = ",";
4614 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4619 char fstype[] = "ext2";
4620 char device[] = "/dev/sda1";
4621 device[5] = devchar;
4624 r = guestfs_mkfs (g, fstype, device);
4629 char device[] = "/dev/sda1";
4630 device[5] = devchar;
4631 char mountpoint[] = "/";
4634 r = guestfs_mount (g, device, mountpoint);
4638 /* TestOutput for mount_ro (1) */
4639 char expected[] = "data";
4641 char path[] = "/new";
4642 char content[] = "data";
4645 r = guestfs_write_file (g, path, content, 0);
4650 char pathordevice[] = "/";
4653 r = guestfs_umount (g, pathordevice);
4658 char device[] = "/dev/sda1";
4659 device[5] = devchar;
4660 char mountpoint[] = "/";
4663 r = guestfs_mount_ro (g, device, mountpoint);
4668 char path[] = "/new";
4671 r = guestfs_cat (g, path);
4674 if (strcmp (r, expected) != 0) {
4675 fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
4683 static int test_tgz_in_0_skip (void)
4687 str = getenv ("SKIP_TEST_TGZ_IN_0");
4688 if (str && strcmp (str, "1") == 0) return 1;
4689 str = getenv ("SKIP_TEST_TGZ_IN");
4690 if (str && strcmp (str, "1") == 0) return 1;
4694 static int test_tgz_in_0 (void)
4696 if (test_tgz_in_0_skip ()) {
4697 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tgz_in_0");
4701 /* InitBasicFS for test_tgz_in_0: create ext2 on /dev/sda1 */
4703 char device[] = "/dev/sda";
4704 device[5] = devchar;
4707 r = guestfs_blockdev_setrw (g, device);
4714 r = guestfs_umount_all (g);
4721 r = guestfs_lvm_remove_all (g);
4726 char device[] = "/dev/sda";
4727 device[5] = devchar;
4728 char lines_0[] = ",";
4735 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4740 char fstype[] = "ext2";
4741 char device[] = "/dev/sda1";
4742 device[5] = devchar;
4745 r = guestfs_mkfs (g, fstype, device);
4750 char device[] = "/dev/sda1";
4751 device[5] = devchar;
4752 char mountpoint[] = "/";
4755 r = guestfs_mount (g, device, mountpoint);
4759 /* TestOutput for tgz_in (0) */
4760 char expected[] = "hello\n";
4762 char directory[] = "/";
4765 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", directory);
4770 char path[] = "/hello";
4773 r = guestfs_cat (g, path);
4776 if (strcmp (r, expected) != 0) {
4777 fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
4785 static int test_tar_in_0_skip (void)
4789 str = getenv ("SKIP_TEST_TAR_IN_0");
4790 if (str && strcmp (str, "1") == 0) return 1;
4791 str = getenv ("SKIP_TEST_TAR_IN");
4792 if (str && strcmp (str, "1") == 0) return 1;
4796 static int test_tar_in_0 (void)
4798 if (test_tar_in_0_skip ()) {
4799 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tar_in_0");
4803 /* InitBasicFS for test_tar_in_0: create ext2 on /dev/sda1 */
4805 char device[] = "/dev/sda";
4806 device[5] = devchar;
4809 r = guestfs_blockdev_setrw (g, device);
4816 r = guestfs_umount_all (g);
4823 r = guestfs_lvm_remove_all (g);
4828 char device[] = "/dev/sda";
4829 device[5] = devchar;
4830 char lines_0[] = ",";
4837 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4842 char fstype[] = "ext2";
4843 char device[] = "/dev/sda1";
4844 device[5] = devchar;
4847 r = guestfs_mkfs (g, fstype, device);
4852 char device[] = "/dev/sda1";
4853 device[5] = devchar;
4854 char mountpoint[] = "/";
4857 r = guestfs_mount (g, device, mountpoint);
4861 /* TestOutput for tar_in (0) */
4862 char expected[] = "hello\n";
4864 char directory[] = "/";
4867 r = guestfs_tar_in (g, "images/helloworld.tar", directory);
4872 char path[] = "/hello";
4875 r = guestfs_cat (g, path);
4878 if (strcmp (r, expected) != 0) {
4879 fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
4887 static int test_checksum_0_skip (void)
4891 str = getenv ("SKIP_TEST_CHECKSUM_0");
4892 if (str && strcmp (str, "1") == 0) return 1;
4893 str = getenv ("SKIP_TEST_CHECKSUM");
4894 if (str && strcmp (str, "1") == 0) return 1;
4898 static int test_checksum_0 (void)
4900 if (test_checksum_0_skip ()) {
4901 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_0");
4905 /* InitBasicFS for test_checksum_0: create ext2 on /dev/sda1 */
4907 char device[] = "/dev/sda";
4908 device[5] = devchar;
4911 r = guestfs_blockdev_setrw (g, device);
4918 r = guestfs_umount_all (g);
4925 r = guestfs_lvm_remove_all (g);
4930 char device[] = "/dev/sda";
4931 device[5] = devchar;
4932 char lines_0[] = ",";
4939 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4944 char fstype[] = "ext2";
4945 char device[] = "/dev/sda1";
4946 device[5] = devchar;
4949 r = guestfs_mkfs (g, fstype, device);
4954 char device[] = "/dev/sda1";
4955 device[5] = devchar;
4956 char mountpoint[] = "/";
4959 r = guestfs_mount (g, device, mountpoint);
4963 /* TestOutput for checksum (0) */
4964 char expected[] = "935282863";
4966 char path[] = "/new";
4967 char content[] = "test\n";
4970 r = guestfs_write_file (g, path, content, 0);
4975 char csumtype[] = "crc";
4976 char path[] = "/new";
4979 r = guestfs_checksum (g, csumtype, path);
4982 if (strcmp (r, expected) != 0) {
4983 fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
4991 static int test_checksum_1_skip (void)
4995 str = getenv ("SKIP_TEST_CHECKSUM_1");
4996 if (str && strcmp (str, "1") == 0) return 1;
4997 str = getenv ("SKIP_TEST_CHECKSUM");
4998 if (str && strcmp (str, "1") == 0) return 1;
5002 static int test_checksum_1 (void)
5004 if (test_checksum_1_skip ()) {
5005 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_1");
5009 /* InitBasicFS for test_checksum_1: create ext2 on /dev/sda1 */
5011 char device[] = "/dev/sda";
5012 device[5] = devchar;
5015 r = guestfs_blockdev_setrw (g, device);
5022 r = guestfs_umount_all (g);
5029 r = guestfs_lvm_remove_all (g);
5034 char device[] = "/dev/sda";
5035 device[5] = devchar;
5036 char lines_0[] = ",";
5043 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5048 char fstype[] = "ext2";
5049 char device[] = "/dev/sda1";
5050 device[5] = devchar;
5053 r = guestfs_mkfs (g, fstype, device);
5058 char device[] = "/dev/sda1";
5059 device[5] = devchar;
5060 char mountpoint[] = "/";
5063 r = guestfs_mount (g, device, mountpoint);
5067 /* TestLastFail for checksum (1) */
5069 char csumtype[] = "crc";
5070 char path[] = "/new";
5073 r = guestfs_checksum (g, csumtype, path);
5081 static int test_checksum_2_skip (void)
5085 str = getenv ("SKIP_TEST_CHECKSUM_2");
5086 if (str && strcmp (str, "1") == 0) return 1;
5087 str = getenv ("SKIP_TEST_CHECKSUM");
5088 if (str && strcmp (str, "1") == 0) return 1;
5092 static int test_checksum_2 (void)
5094 if (test_checksum_2_skip ()) {
5095 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_2");
5099 /* InitBasicFS for test_checksum_2: create ext2 on /dev/sda1 */
5101 char device[] = "/dev/sda";
5102 device[5] = devchar;
5105 r = guestfs_blockdev_setrw (g, device);
5112 r = guestfs_umount_all (g);
5119 r = guestfs_lvm_remove_all (g);
5124 char device[] = "/dev/sda";
5125 device[5] = devchar;
5126 char lines_0[] = ",";
5133 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5138 char fstype[] = "ext2";
5139 char device[] = "/dev/sda1";
5140 device[5] = devchar;
5143 r = guestfs_mkfs (g, fstype, device);
5148 char device[] = "/dev/sda1";
5149 device[5] = devchar;
5150 char mountpoint[] = "/";
5153 r = guestfs_mount (g, device, mountpoint);
5157 /* TestOutput for checksum (2) */
5158 char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
5160 char path[] = "/new";
5161 char content[] = "test\n";
5164 r = guestfs_write_file (g, path, content, 0);
5169 char csumtype[] = "md5";
5170 char path[] = "/new";
5173 r = guestfs_checksum (g, csumtype, path);
5176 if (strcmp (r, expected) != 0) {
5177 fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
5185 static int test_checksum_3_skip (void)
5189 str = getenv ("SKIP_TEST_CHECKSUM_3");
5190 if (str && strcmp (str, "1") == 0) return 1;
5191 str = getenv ("SKIP_TEST_CHECKSUM");
5192 if (str && strcmp (str, "1") == 0) return 1;
5196 static int test_checksum_3 (void)
5198 if (test_checksum_3_skip ()) {
5199 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_3");
5203 /* InitBasicFS for test_checksum_3: create ext2 on /dev/sda1 */
5205 char device[] = "/dev/sda";
5206 device[5] = devchar;
5209 r = guestfs_blockdev_setrw (g, device);
5216 r = guestfs_umount_all (g);
5223 r = guestfs_lvm_remove_all (g);
5228 char device[] = "/dev/sda";
5229 device[5] = devchar;
5230 char lines_0[] = ",";
5237 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5242 char fstype[] = "ext2";
5243 char device[] = "/dev/sda1";
5244 device[5] = devchar;
5247 r = guestfs_mkfs (g, fstype, device);
5252 char device[] = "/dev/sda1";
5253 device[5] = devchar;
5254 char mountpoint[] = "/";
5257 r = guestfs_mount (g, device, mountpoint);
5261 /* TestOutput for checksum (3) */
5262 char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
5264 char path[] = "/new";
5265 char content[] = "test\n";
5268 r = guestfs_write_file (g, path, content, 0);
5273 char csumtype[] = "sha1";
5274 char path[] = "/new";
5277 r = guestfs_checksum (g, csumtype, path);
5280 if (strcmp (r, expected) != 0) {
5281 fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
5289 static int test_checksum_4_skip (void)
5293 str = getenv ("SKIP_TEST_CHECKSUM_4");
5294 if (str && strcmp (str, "1") == 0) return 1;
5295 str = getenv ("SKIP_TEST_CHECKSUM");
5296 if (str && strcmp (str, "1") == 0) return 1;
5300 static int test_checksum_4 (void)
5302 if (test_checksum_4_skip ()) {
5303 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_4");
5307 /* InitBasicFS for test_checksum_4: create ext2 on /dev/sda1 */
5309 char device[] = "/dev/sda";
5310 device[5] = devchar;
5313 r = guestfs_blockdev_setrw (g, device);
5320 r = guestfs_umount_all (g);
5327 r = guestfs_lvm_remove_all (g);
5332 char device[] = "/dev/sda";
5333 device[5] = devchar;
5334 char lines_0[] = ",";
5341 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5346 char fstype[] = "ext2";
5347 char device[] = "/dev/sda1";
5348 device[5] = devchar;
5351 r = guestfs_mkfs (g, fstype, device);
5356 char device[] = "/dev/sda1";
5357 device[5] = devchar;
5358 char mountpoint[] = "/";
5361 r = guestfs_mount (g, device, mountpoint);
5365 /* TestOutput for checksum (4) */
5366 char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
5368 char path[] = "/new";
5369 char content[] = "test\n";
5372 r = guestfs_write_file (g, path, content, 0);
5377 char csumtype[] = "sha224";
5378 char path[] = "/new";
5381 r = guestfs_checksum (g, csumtype, path);
5384 if (strcmp (r, expected) != 0) {
5385 fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
5393 static int test_checksum_5_skip (void)
5397 str = getenv ("SKIP_TEST_CHECKSUM_5");
5398 if (str && strcmp (str, "1") == 0) return 1;
5399 str = getenv ("SKIP_TEST_CHECKSUM");
5400 if (str && strcmp (str, "1") == 0) return 1;
5404 static int test_checksum_5 (void)
5406 if (test_checksum_5_skip ()) {
5407 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_5");
5411 /* InitBasicFS for test_checksum_5: create ext2 on /dev/sda1 */
5413 char device[] = "/dev/sda";
5414 device[5] = devchar;
5417 r = guestfs_blockdev_setrw (g, device);
5424 r = guestfs_umount_all (g);
5431 r = guestfs_lvm_remove_all (g);
5436 char device[] = "/dev/sda";
5437 device[5] = devchar;
5438 char lines_0[] = ",";
5445 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5450 char fstype[] = "ext2";
5451 char device[] = "/dev/sda1";
5452 device[5] = devchar;
5455 r = guestfs_mkfs (g, fstype, device);
5460 char device[] = "/dev/sda1";
5461 device[5] = devchar;
5462 char mountpoint[] = "/";
5465 r = guestfs_mount (g, device, mountpoint);
5469 /* TestOutput for checksum (5) */
5470 char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
5472 char path[] = "/new";
5473 char content[] = "test\n";
5476 r = guestfs_write_file (g, path, content, 0);
5481 char csumtype[] = "sha256";
5482 char path[] = "/new";
5485 r = guestfs_checksum (g, csumtype, path);
5488 if (strcmp (r, expected) != 0) {
5489 fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
5497 static int test_checksum_6_skip (void)
5501 str = getenv ("SKIP_TEST_CHECKSUM_6");
5502 if (str && strcmp (str, "1") == 0) return 1;
5503 str = getenv ("SKIP_TEST_CHECKSUM");
5504 if (str && strcmp (str, "1") == 0) return 1;
5508 static int test_checksum_6 (void)
5510 if (test_checksum_6_skip ()) {
5511 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_6");
5515 /* InitBasicFS for test_checksum_6: create ext2 on /dev/sda1 */
5517 char device[] = "/dev/sda";
5518 device[5] = devchar;
5521 r = guestfs_blockdev_setrw (g, device);
5528 r = guestfs_umount_all (g);
5535 r = guestfs_lvm_remove_all (g);
5540 char device[] = "/dev/sda";
5541 device[5] = devchar;
5542 char lines_0[] = ",";
5549 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5554 char fstype[] = "ext2";
5555 char device[] = "/dev/sda1";
5556 device[5] = devchar;
5559 r = guestfs_mkfs (g, fstype, device);
5564 char device[] = "/dev/sda1";
5565 device[5] = devchar;
5566 char mountpoint[] = "/";
5569 r = guestfs_mount (g, device, mountpoint);
5573 /* TestOutput for checksum (6) */
5574 char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
5576 char path[] = "/new";
5577 char content[] = "test\n";
5580 r = guestfs_write_file (g, path, content, 0);
5585 char csumtype[] = "sha384";
5586 char path[] = "/new";
5589 r = guestfs_checksum (g, csumtype, path);
5592 if (strcmp (r, expected) != 0) {
5593 fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
5601 static int test_checksum_7_skip (void)
5605 str = getenv ("SKIP_TEST_CHECKSUM_7");
5606 if (str && strcmp (str, "1") == 0) return 1;
5607 str = getenv ("SKIP_TEST_CHECKSUM");
5608 if (str && strcmp (str, "1") == 0) return 1;
5612 static int test_checksum_7 (void)
5614 if (test_checksum_7_skip ()) {
5615 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_7");
5619 /* InitBasicFS for test_checksum_7: create ext2 on /dev/sda1 */
5621 char device[] = "/dev/sda";
5622 device[5] = devchar;
5625 r = guestfs_blockdev_setrw (g, device);
5632 r = guestfs_umount_all (g);
5639 r = guestfs_lvm_remove_all (g);
5644 char device[] = "/dev/sda";
5645 device[5] = devchar;
5646 char lines_0[] = ",";
5653 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5658 char fstype[] = "ext2";
5659 char device[] = "/dev/sda1";
5660 device[5] = devchar;
5663 r = guestfs_mkfs (g, fstype, device);
5668 char device[] = "/dev/sda1";
5669 device[5] = devchar;
5670 char mountpoint[] = "/";
5673 r = guestfs_mount (g, device, mountpoint);
5677 /* TestOutput for checksum (7) */
5678 char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
5680 char path[] = "/new";
5681 char content[] = "test\n";
5684 r = guestfs_write_file (g, path, content, 0);
5689 char csumtype[] = "sha512";
5690 char path[] = "/new";
5693 r = guestfs_checksum (g, csumtype, path);
5696 if (strcmp (r, expected) != 0) {
5697 fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
5705 static int test_download_0_skip (void)
5709 str = getenv ("SKIP_TEST_DOWNLOAD_0");
5710 if (str && strcmp (str, "1") == 0) return 1;
5711 str = getenv ("SKIP_TEST_DOWNLOAD");
5712 if (str && strcmp (str, "1") == 0) return 1;
5716 static int test_download_0 (void)
5718 if (test_download_0_skip ()) {
5719 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_download_0");
5723 /* InitBasicFS for test_download_0: create ext2 on /dev/sda1 */
5725 char device[] = "/dev/sda";
5726 device[5] = devchar;
5729 r = guestfs_blockdev_setrw (g, device);
5736 r = guestfs_umount_all (g);
5743 r = guestfs_lvm_remove_all (g);
5748 char device[] = "/dev/sda";
5749 device[5] = devchar;
5750 char lines_0[] = ",";
5757 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5762 char fstype[] = "ext2";
5763 char device[] = "/dev/sda1";
5764 device[5] = devchar;
5767 r = guestfs_mkfs (g, fstype, device);
5772 char device[] = "/dev/sda1";
5773 device[5] = devchar;
5774 char mountpoint[] = "/";
5777 r = guestfs_mount (g, device, mountpoint);
5781 /* TestOutput for download (0) */
5782 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
5784 char remotefilename[] = "/COPYING.LIB";
5787 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
5792 char remotefilename[] = "/COPYING.LIB";
5795 r = guestfs_download (g, remotefilename, "testdownload.tmp");
5800 char remotefilename[] = "/upload";
5803 r = guestfs_upload (g, "testdownload.tmp", remotefilename);
5808 char csumtype[] = "md5";
5809 char path[] = "/upload";
5812 r = guestfs_checksum (g, csumtype, path);
5815 if (strcmp (r, expected) != 0) {
5816 fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
5824 static int test_upload_0_skip (void)
5828 str = getenv ("SKIP_TEST_UPLOAD_0");
5829 if (str && strcmp (str, "1") == 0) return 1;
5830 str = getenv ("SKIP_TEST_UPLOAD");
5831 if (str && strcmp (str, "1") == 0) return 1;
5835 static int test_upload_0 (void)
5837 if (test_upload_0_skip ()) {
5838 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_upload_0");
5842 /* InitBasicFS for test_upload_0: create ext2 on /dev/sda1 */
5844 char device[] = "/dev/sda";
5845 device[5] = devchar;
5848 r = guestfs_blockdev_setrw (g, device);
5855 r = guestfs_umount_all (g);
5862 r = guestfs_lvm_remove_all (g);
5867 char device[] = "/dev/sda";
5868 device[5] = devchar;
5869 char lines_0[] = ",";
5876 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5881 char fstype[] = "ext2";
5882 char device[] = "/dev/sda1";
5883 device[5] = devchar;
5886 r = guestfs_mkfs (g, fstype, device);
5891 char device[] = "/dev/sda1";
5892 device[5] = devchar;
5893 char mountpoint[] = "/";
5896 r = guestfs_mount (g, device, mountpoint);
5900 /* TestOutput for upload (0) */
5901 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
5903 char remotefilename[] = "/COPYING.LIB";
5906 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
5911 char csumtype[] = "md5";
5912 char path[] = "/COPYING.LIB";
5915 r = guestfs_checksum (g, csumtype, path);
5918 if (strcmp (r, expected) != 0) {
5919 fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
5927 static int test_blockdev_rereadpt_0_skip (void)
5931 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT_0");
5932 if (str && strcmp (str, "1") == 0) return 1;
5933 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT");
5934 if (str && strcmp (str, "1") == 0) return 1;
5938 static int test_blockdev_rereadpt_0 (void)
5940 if (test_blockdev_rereadpt_0_skip ()) {
5941 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_rereadpt_0");
5945 /* InitNone|InitEmpty for test_blockdev_rereadpt_0 */
5947 char device[] = "/dev/sda";
5948 device[5] = devchar;
5951 r = guestfs_blockdev_setrw (g, device);
5958 r = guestfs_umount_all (g);
5965 r = guestfs_lvm_remove_all (g);
5969 /* TestRun for blockdev_rereadpt (0) */
5971 char device[] = "/dev/sda";
5972 device[5] = devchar;
5975 r = guestfs_blockdev_rereadpt (g, device);
5982 static int test_blockdev_flushbufs_0_skip (void)
5986 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS_0");
5987 if (str && strcmp (str, "1") == 0) return 1;
5988 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS");
5989 if (str && strcmp (str, "1") == 0) return 1;
5993 static int test_blockdev_flushbufs_0 (void)
5995 if (test_blockdev_flushbufs_0_skip ()) {
5996 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_flushbufs_0");
6000 /* InitNone|InitEmpty for test_blockdev_flushbufs_0 */
6002 char device[] = "/dev/sda";
6003 device[5] = devchar;
6006 r = guestfs_blockdev_setrw (g, device);
6013 r = guestfs_umount_all (g);
6020 r = guestfs_lvm_remove_all (g);
6024 /* TestRun for blockdev_flushbufs (0) */
6026 char device[] = "/dev/sda";
6027 device[5] = devchar;
6030 r = guestfs_blockdev_flushbufs (g, device);
6037 static int test_blockdev_getsize64_0_skip (void)
6041 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64_0");
6042 if (str && strcmp (str, "1") == 0) return 1;
6043 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64");
6044 if (str && strcmp (str, "1") == 0) return 1;
6048 static int test_blockdev_getsize64_0 (void)
6050 if (test_blockdev_getsize64_0_skip ()) {
6051 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsize64_0");
6055 /* InitNone|InitEmpty for test_blockdev_getsize64_0 */
6057 char device[] = "/dev/sda";
6058 device[5] = devchar;
6061 r = guestfs_blockdev_setrw (g, device);
6068 r = guestfs_umount_all (g);
6075 r = guestfs_lvm_remove_all (g);
6079 /* TestOutputInt for blockdev_getsize64 (0) */
6081 char device[] = "/dev/sda";
6082 device[5] = devchar;
6085 r = guestfs_blockdev_getsize64 (g, device);
6088 if (r != 524288000) {
6089 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
6096 static int test_blockdev_getsz_0_skip (void)
6100 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ_0");
6101 if (str && strcmp (str, "1") == 0) return 1;
6102 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ");
6103 if (str && strcmp (str, "1") == 0) return 1;
6107 static int test_blockdev_getsz_0 (void)
6109 if (test_blockdev_getsz_0_skip ()) {
6110 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsz_0");
6114 /* InitNone|InitEmpty for test_blockdev_getsz_0 */
6116 char device[] = "/dev/sda";
6117 device[5] = devchar;
6120 r = guestfs_blockdev_setrw (g, device);
6127 r = guestfs_umount_all (g);
6134 r = guestfs_lvm_remove_all (g);
6138 /* TestOutputInt for blockdev_getsz (0) */
6140 char device[] = "/dev/sda";
6141 device[5] = devchar;
6144 r = guestfs_blockdev_getsz (g, device);
6148 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
6155 static int test_blockdev_getbsz_0_skip (void)
6159 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ_0");
6160 if (str && strcmp (str, "1") == 0) return 1;
6161 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ");
6162 if (str && strcmp (str, "1") == 0) return 1;
6166 static int test_blockdev_getbsz_0 (void)
6168 if (test_blockdev_getbsz_0_skip ()) {
6169 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getbsz_0");
6173 /* InitNone|InitEmpty for test_blockdev_getbsz_0 */
6175 char device[] = "/dev/sda";
6176 device[5] = devchar;
6179 r = guestfs_blockdev_setrw (g, device);
6186 r = guestfs_umount_all (g);
6193 r = guestfs_lvm_remove_all (g);
6197 /* TestOutputInt for blockdev_getbsz (0) */
6199 char device[] = "/dev/sda";
6200 device[5] = devchar;
6203 r = guestfs_blockdev_getbsz (g, device);
6207 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
6214 static int test_blockdev_getss_0_skip (void)
6218 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS_0");
6219 if (str && strcmp (str, "1") == 0) return 1;
6220 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS");
6221 if (str && strcmp (str, "1") == 0) return 1;
6225 static int test_blockdev_getss_0 (void)
6227 if (test_blockdev_getss_0_skip ()) {
6228 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getss_0");
6232 /* InitNone|InitEmpty for test_blockdev_getss_0 */
6234 char device[] = "/dev/sda";
6235 device[5] = devchar;
6238 r = guestfs_blockdev_setrw (g, device);
6245 r = guestfs_umount_all (g);
6252 r = guestfs_lvm_remove_all (g);
6256 /* TestOutputInt for blockdev_getss (0) */
6258 char device[] = "/dev/sda";
6259 device[5] = devchar;
6262 r = guestfs_blockdev_getss (g, device);
6266 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
6273 static int test_blockdev_getro_0_skip (void)
6277 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO_0");
6278 if (str && strcmp (str, "1") == 0) return 1;
6279 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO");
6280 if (str && strcmp (str, "1") == 0) return 1;
6284 static int test_blockdev_getro_0 (void)
6286 if (test_blockdev_getro_0_skip ()) {
6287 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getro_0");
6291 /* InitNone|InitEmpty for test_blockdev_getro_0 */
6293 char device[] = "/dev/sda";
6294 device[5] = devchar;
6297 r = guestfs_blockdev_setrw (g, device);
6304 r = guestfs_umount_all (g);
6311 r = guestfs_lvm_remove_all (g);
6315 /* TestOutputTrue for blockdev_getro (0) */
6317 char device[] = "/dev/sda";
6318 device[5] = devchar;
6321 r = guestfs_blockdev_setro (g, device);
6326 char device[] = "/dev/sda";
6327 device[5] = devchar;
6330 r = guestfs_blockdev_getro (g, device);
6334 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
6341 static int test_blockdev_setrw_0_skip (void)
6345 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW_0");
6346 if (str && strcmp (str, "1") == 0) return 1;
6347 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW");
6348 if (str && strcmp (str, "1") == 0) return 1;
6352 static int test_blockdev_setrw_0 (void)
6354 if (test_blockdev_setrw_0_skip ()) {
6355 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setrw_0");
6359 /* InitNone|InitEmpty for test_blockdev_setrw_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 /* TestOutputFalse for blockdev_setrw (0) */
6385 char device[] = "/dev/sda";
6386 device[5] = devchar;
6389 r = guestfs_blockdev_setrw (g, device);
6394 char device[] = "/dev/sda";
6395 device[5] = devchar;
6398 r = guestfs_blockdev_getro (g, device);
6402 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
6409 static int test_blockdev_setro_0_skip (void)
6413 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO_0");
6414 if (str && strcmp (str, "1") == 0) return 1;
6415 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO");
6416 if (str && strcmp (str, "1") == 0) return 1;
6420 static int test_blockdev_setro_0 (void)
6422 if (test_blockdev_setro_0_skip ()) {
6423 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setro_0");
6427 /* InitNone|InitEmpty for test_blockdev_setro_0 */
6429 char device[] = "/dev/sda";
6430 device[5] = devchar;
6433 r = guestfs_blockdev_setrw (g, device);
6440 r = guestfs_umount_all (g);
6447 r = guestfs_lvm_remove_all (g);
6451 /* TestOutputTrue for blockdev_setro (0) */
6453 char device[] = "/dev/sda";
6454 device[5] = devchar;
6457 r = guestfs_blockdev_setro (g, device);
6462 char device[] = "/dev/sda";
6463 device[5] = devchar;
6466 r = guestfs_blockdev_getro (g, device);
6470 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
6477 static int test_statvfs_0_skip (void)
6481 str = getenv ("SKIP_TEST_STATVFS_0");
6482 if (str && strcmp (str, "1") == 0) return 1;
6483 str = getenv ("SKIP_TEST_STATVFS");
6484 if (str && strcmp (str, "1") == 0) return 1;
6488 static int test_statvfs_0 (void)
6490 if (test_statvfs_0_skip ()) {
6491 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_statvfs_0");
6495 /* InitBasicFS for test_statvfs_0: create ext2 on /dev/sda1 */
6497 char device[] = "/dev/sda";
6498 device[5] = devchar;
6501 r = guestfs_blockdev_setrw (g, device);
6508 r = guestfs_umount_all (g);
6515 r = guestfs_lvm_remove_all (g);
6520 char device[] = "/dev/sda";
6521 device[5] = devchar;
6522 char lines_0[] = ",";
6529 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6534 char fstype[] = "ext2";
6535 char device[] = "/dev/sda1";
6536 device[5] = devchar;
6539 r = guestfs_mkfs (g, fstype, device);
6544 char device[] = "/dev/sda1";
6545 device[5] = devchar;
6546 char mountpoint[] = "/";
6549 r = guestfs_mount (g, device, mountpoint);
6553 /* TestOutputStruct for statvfs (0) */
6556 struct guestfs_statvfs *r;
6558 r = guestfs_statvfs (g, path);
6561 if (r->bfree != 487702) {
6562 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
6566 if (r->blocks != 490020) {
6567 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
6571 if (r->bsize != 1024) {
6572 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
6581 static int test_lstat_0_skip (void)
6585 str = getenv ("SKIP_TEST_LSTAT_0");
6586 if (str && strcmp (str, "1") == 0) return 1;
6587 str = getenv ("SKIP_TEST_LSTAT");
6588 if (str && strcmp (str, "1") == 0) return 1;
6592 static int test_lstat_0 (void)
6594 if (test_lstat_0_skip ()) {
6595 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lstat_0");
6599 /* InitBasicFS for test_lstat_0: create ext2 on /dev/sda1 */
6601 char device[] = "/dev/sda";
6602 device[5] = devchar;
6605 r = guestfs_blockdev_setrw (g, device);
6612 r = guestfs_umount_all (g);
6619 r = guestfs_lvm_remove_all (g);
6624 char device[] = "/dev/sda";
6625 device[5] = devchar;
6626 char lines_0[] = ",";
6633 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6638 char fstype[] = "ext2";
6639 char device[] = "/dev/sda1";
6640 device[5] = devchar;
6643 r = guestfs_mkfs (g, fstype, device);
6648 char device[] = "/dev/sda1";
6649 device[5] = devchar;
6650 char mountpoint[] = "/";
6653 r = guestfs_mount (g, device, mountpoint);
6657 /* TestOutputStruct for lstat (0) */
6659 char path[] = "/new";
6662 r = guestfs_touch (g, path);
6667 char path[] = "/new";
6668 struct guestfs_stat *r;
6670 r = guestfs_lstat (g, path);
6674 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
6683 static int test_stat_0_skip (void)
6687 str = getenv ("SKIP_TEST_STAT_0");
6688 if (str && strcmp (str, "1") == 0) return 1;
6689 str = getenv ("SKIP_TEST_STAT");
6690 if (str && strcmp (str, "1") == 0) return 1;
6694 static int test_stat_0 (void)
6696 if (test_stat_0_skip ()) {
6697 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_stat_0");
6701 /* InitBasicFS for test_stat_0: create ext2 on /dev/sda1 */
6703 char device[] = "/dev/sda";
6704 device[5] = devchar;
6707 r = guestfs_blockdev_setrw (g, device);
6714 r = guestfs_umount_all (g);
6721 r = guestfs_lvm_remove_all (g);
6726 char device[] = "/dev/sda";
6727 device[5] = devchar;
6728 char lines_0[] = ",";
6735 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6740 char fstype[] = "ext2";
6741 char device[] = "/dev/sda1";
6742 device[5] = devchar;
6745 r = guestfs_mkfs (g, fstype, device);
6750 char device[] = "/dev/sda1";
6751 device[5] = devchar;
6752 char mountpoint[] = "/";
6755 r = guestfs_mount (g, device, mountpoint);
6759 /* TestOutputStruct for stat (0) */
6761 char path[] = "/new";
6764 r = guestfs_touch (g, path);
6769 char path[] = "/new";
6770 struct guestfs_stat *r;
6772 r = guestfs_stat (g, path);
6776 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
6785 static int test_command_lines_0_skip (void)
6789 str = getenv ("SKIP_TEST_COMMAND_LINES_0");
6790 if (str && strcmp (str, "1") == 0) return 1;
6791 str = getenv ("SKIP_TEST_COMMAND_LINES");
6792 if (str && strcmp (str, "1") == 0) return 1;
6796 static int test_command_lines_0 (void)
6798 if (test_command_lines_0_skip ()) {
6799 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_0");
6803 /* InitBasicFS for test_command_lines_0: create ext2 on /dev/sda1 */
6805 char device[] = "/dev/sda";
6806 device[5] = devchar;
6809 r = guestfs_blockdev_setrw (g, device);
6816 r = guestfs_umount_all (g);
6823 r = guestfs_lvm_remove_all (g);
6828 char device[] = "/dev/sda";
6829 device[5] = devchar;
6830 char lines_0[] = ",";
6837 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6842 char fstype[] = "ext2";
6843 char device[] = "/dev/sda1";
6844 device[5] = devchar;
6847 r = guestfs_mkfs (g, fstype, device);
6852 char device[] = "/dev/sda1";
6853 device[5] = devchar;
6854 char mountpoint[] = "/";
6857 r = guestfs_mount (g, device, mountpoint);
6861 /* TestOutputList for command_lines (0) */
6863 char remotefilename[] = "/test-command";
6866 r = guestfs_upload (g, "test-command", remotefilename);
6871 char path[] = "/test-command";
6874 r = guestfs_chmod (g, 493, path);
6879 char arguments_0[] = "/test-command";
6880 char arguments_1[] = "1";
6881 char *arguments[] = {
6889 r = guestfs_command_lines (g, arguments);
6893 fprintf (stderr, "test_command_lines_0: short list returned from command\n");
6898 char expected[] = "Result1";
6899 if (strcmp (r[0], expected) != 0) {
6900 fprintf (stderr, "test_command_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6905 fprintf (stderr, "test_command_lines_0: extra elements returned from command\n");
6909 for (i = 0; r[i] != NULL; ++i)
6916 static int test_command_lines_1_skip (void)
6920 str = getenv ("SKIP_TEST_COMMAND_LINES_1");
6921 if (str && strcmp (str, "1") == 0) return 1;
6922 str = getenv ("SKIP_TEST_COMMAND_LINES");
6923 if (str && strcmp (str, "1") == 0) return 1;
6927 static int test_command_lines_1 (void)
6929 if (test_command_lines_1_skip ()) {
6930 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_1");
6934 /* InitBasicFS for test_command_lines_1: create ext2 on /dev/sda1 */
6936 char device[] = "/dev/sda";
6937 device[5] = devchar;
6940 r = guestfs_blockdev_setrw (g, device);
6947 r = guestfs_umount_all (g);
6954 r = guestfs_lvm_remove_all (g);
6959 char device[] = "/dev/sda";
6960 device[5] = devchar;
6961 char lines_0[] = ",";
6968 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6973 char fstype[] = "ext2";
6974 char device[] = "/dev/sda1";
6975 device[5] = devchar;
6978 r = guestfs_mkfs (g, fstype, device);
6983 char device[] = "/dev/sda1";
6984 device[5] = devchar;
6985 char mountpoint[] = "/";
6988 r = guestfs_mount (g, device, mountpoint);
6992 /* TestOutputList for command_lines (1) */
6994 char remotefilename[] = "/test-command";
6997 r = guestfs_upload (g, "test-command", remotefilename);
7002 char path[] = "/test-command";
7005 r = guestfs_chmod (g, 493, path);
7010 char arguments_0[] = "/test-command";
7011 char arguments_1[] = "2";
7012 char *arguments[] = {
7020 r = guestfs_command_lines (g, arguments);
7024 fprintf (stderr, "test_command_lines_1: short list returned from command\n");
7029 char expected[] = "Result2";
7030 if (strcmp (r[0], expected) != 0) {
7031 fprintf (stderr, "test_command_lines_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7036 fprintf (stderr, "test_command_lines_1: extra elements returned from command\n");
7040 for (i = 0; r[i] != NULL; ++i)
7047 static int test_command_lines_2_skip (void)
7051 str = getenv ("SKIP_TEST_COMMAND_LINES_2");
7052 if (str && strcmp (str, "1") == 0) return 1;
7053 str = getenv ("SKIP_TEST_COMMAND_LINES");
7054 if (str && strcmp (str, "1") == 0) return 1;
7058 static int test_command_lines_2 (void)
7060 if (test_command_lines_2_skip ()) {
7061 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_2");
7065 /* InitBasicFS for test_command_lines_2: create ext2 on /dev/sda1 */
7067 char device[] = "/dev/sda";
7068 device[5] = devchar;
7071 r = guestfs_blockdev_setrw (g, device);
7078 r = guestfs_umount_all (g);
7085 r = guestfs_lvm_remove_all (g);
7090 char device[] = "/dev/sda";
7091 device[5] = devchar;
7092 char lines_0[] = ",";
7099 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7104 char fstype[] = "ext2";
7105 char device[] = "/dev/sda1";
7106 device[5] = devchar;
7109 r = guestfs_mkfs (g, fstype, device);
7114 char device[] = "/dev/sda1";
7115 device[5] = devchar;
7116 char mountpoint[] = "/";
7119 r = guestfs_mount (g, device, mountpoint);
7123 /* TestOutputList for command_lines (2) */
7125 char remotefilename[] = "/test-command";
7128 r = guestfs_upload (g, "test-command", remotefilename);
7133 char path[] = "/test-command";
7136 r = guestfs_chmod (g, 493, path);
7141 char arguments_0[] = "/test-command";
7142 char arguments_1[] = "3";
7143 char *arguments[] = {
7151 r = guestfs_command_lines (g, arguments);
7155 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7160 char expected[] = "";
7161 if (strcmp (r[0], expected) != 0) {
7162 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7167 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7172 char expected[] = "Result3";
7173 if (strcmp (r[1], expected) != 0) {
7174 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7179 fprintf (stderr, "test_command_lines_2: extra elements returned from command\n");
7183 for (i = 0; r[i] != NULL; ++i)
7190 static int test_command_lines_3_skip (void)
7194 str = getenv ("SKIP_TEST_COMMAND_LINES_3");
7195 if (str && strcmp (str, "1") == 0) return 1;
7196 str = getenv ("SKIP_TEST_COMMAND_LINES");
7197 if (str && strcmp (str, "1") == 0) return 1;
7201 static int test_command_lines_3 (void)
7203 if (test_command_lines_3_skip ()) {
7204 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_3");
7208 /* InitBasicFS for test_command_lines_3: create ext2 on /dev/sda1 */
7210 char device[] = "/dev/sda";
7211 device[5] = devchar;
7214 r = guestfs_blockdev_setrw (g, device);
7221 r = guestfs_umount_all (g);
7228 r = guestfs_lvm_remove_all (g);
7233 char device[] = "/dev/sda";
7234 device[5] = devchar;
7235 char lines_0[] = ",";
7242 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7247 char fstype[] = "ext2";
7248 char device[] = "/dev/sda1";
7249 device[5] = devchar;
7252 r = guestfs_mkfs (g, fstype, device);
7257 char device[] = "/dev/sda1";
7258 device[5] = devchar;
7259 char mountpoint[] = "/";
7262 r = guestfs_mount (g, device, mountpoint);
7266 /* TestOutputList for command_lines (3) */
7268 char remotefilename[] = "/test-command";
7271 r = guestfs_upload (g, "test-command", remotefilename);
7276 char path[] = "/test-command";
7279 r = guestfs_chmod (g, 493, path);
7284 char arguments_0[] = "/test-command";
7285 char arguments_1[] = "4";
7286 char *arguments[] = {
7294 r = guestfs_command_lines (g, arguments);
7298 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
7303 char expected[] = "";
7304 if (strcmp (r[0], expected) != 0) {
7305 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7310 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
7315 char expected[] = "Result4";
7316 if (strcmp (r[1], expected) != 0) {
7317 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7322 fprintf (stderr, "test_command_lines_3: extra elements returned from command\n");
7326 for (i = 0; r[i] != NULL; ++i)
7333 static int test_command_lines_4_skip (void)
7337 str = getenv ("SKIP_TEST_COMMAND_LINES_4");
7338 if (str && strcmp (str, "1") == 0) return 1;
7339 str = getenv ("SKIP_TEST_COMMAND_LINES");
7340 if (str && strcmp (str, "1") == 0) return 1;
7344 static int test_command_lines_4 (void)
7346 if (test_command_lines_4_skip ()) {
7347 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_4");
7351 /* InitBasicFS for test_command_lines_4: create ext2 on /dev/sda1 */
7353 char device[] = "/dev/sda";
7354 device[5] = devchar;
7357 r = guestfs_blockdev_setrw (g, device);
7364 r = guestfs_umount_all (g);
7371 r = guestfs_lvm_remove_all (g);
7376 char device[] = "/dev/sda";
7377 device[5] = devchar;
7378 char lines_0[] = ",";
7385 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7390 char fstype[] = "ext2";
7391 char device[] = "/dev/sda1";
7392 device[5] = devchar;
7395 r = guestfs_mkfs (g, fstype, device);
7400 char device[] = "/dev/sda1";
7401 device[5] = devchar;
7402 char mountpoint[] = "/";
7405 r = guestfs_mount (g, device, mountpoint);
7409 /* TestOutputList for command_lines (4) */
7411 char remotefilename[] = "/test-command";
7414 r = guestfs_upload (g, "test-command", remotefilename);
7419 char path[] = "/test-command";
7422 r = guestfs_chmod (g, 493, path);
7427 char arguments_0[] = "/test-command";
7428 char arguments_1[] = "5";
7429 char *arguments[] = {
7437 r = guestfs_command_lines (g, arguments);
7441 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7446 char expected[] = "";
7447 if (strcmp (r[0], expected) != 0) {
7448 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7453 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7458 char expected[] = "Result5";
7459 if (strcmp (r[1], expected) != 0) {
7460 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7465 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7470 char expected[] = "";
7471 if (strcmp (r[2], expected) != 0) {
7472 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[2]);
7477 fprintf (stderr, "test_command_lines_4: extra elements returned from command\n");
7481 for (i = 0; r[i] != NULL; ++i)
7488 static int test_command_lines_5_skip (void)
7492 str = getenv ("SKIP_TEST_COMMAND_LINES_5");
7493 if (str && strcmp (str, "1") == 0) return 1;
7494 str = getenv ("SKIP_TEST_COMMAND_LINES");
7495 if (str && strcmp (str, "1") == 0) return 1;
7499 static int test_command_lines_5 (void)
7501 if (test_command_lines_5_skip ()) {
7502 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_5");
7506 /* InitBasicFS for test_command_lines_5: create ext2 on /dev/sda1 */
7508 char device[] = "/dev/sda";
7509 device[5] = devchar;
7512 r = guestfs_blockdev_setrw (g, device);
7519 r = guestfs_umount_all (g);
7526 r = guestfs_lvm_remove_all (g);
7531 char device[] = "/dev/sda";
7532 device[5] = devchar;
7533 char lines_0[] = ",";
7540 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7545 char fstype[] = "ext2";
7546 char device[] = "/dev/sda1";
7547 device[5] = devchar;
7550 r = guestfs_mkfs (g, fstype, device);
7555 char device[] = "/dev/sda1";
7556 device[5] = devchar;
7557 char mountpoint[] = "/";
7560 r = guestfs_mount (g, device, mountpoint);
7564 /* TestOutputList for command_lines (5) */
7566 char remotefilename[] = "/test-command";
7569 r = guestfs_upload (g, "test-command", remotefilename);
7574 char path[] = "/test-command";
7577 r = guestfs_chmod (g, 493, path);
7582 char arguments_0[] = "/test-command";
7583 char arguments_1[] = "6";
7584 char *arguments[] = {
7592 r = guestfs_command_lines (g, arguments);
7596 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7601 char expected[] = "";
7602 if (strcmp (r[0], expected) != 0) {
7603 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7608 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7613 char expected[] = "";
7614 if (strcmp (r[1], expected) != 0) {
7615 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7620 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7625 char expected[] = "Result6";
7626 if (strcmp (r[2], expected) != 0) {
7627 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[2]);
7632 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7637 char expected[] = "";
7638 if (strcmp (r[3], expected) != 0) {
7639 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[3]);
7644 fprintf (stderr, "test_command_lines_5: extra elements returned from command\n");
7648 for (i = 0; r[i] != NULL; ++i)
7655 static int test_command_lines_6_skip (void)
7659 str = getenv ("SKIP_TEST_COMMAND_LINES_6");
7660 if (str && strcmp (str, "1") == 0) return 1;
7661 str = getenv ("SKIP_TEST_COMMAND_LINES");
7662 if (str && strcmp (str, "1") == 0) return 1;
7666 static int test_command_lines_6 (void)
7668 if (test_command_lines_6_skip ()) {
7669 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_6");
7673 /* InitBasicFS for test_command_lines_6: create ext2 on /dev/sda1 */
7675 char device[] = "/dev/sda";
7676 device[5] = devchar;
7679 r = guestfs_blockdev_setrw (g, device);
7686 r = guestfs_umount_all (g);
7693 r = guestfs_lvm_remove_all (g);
7698 char device[] = "/dev/sda";
7699 device[5] = devchar;
7700 char lines_0[] = ",";
7707 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7712 char fstype[] = "ext2";
7713 char device[] = "/dev/sda1";
7714 device[5] = devchar;
7717 r = guestfs_mkfs (g, fstype, device);
7722 char device[] = "/dev/sda1";
7723 device[5] = devchar;
7724 char mountpoint[] = "/";
7727 r = guestfs_mount (g, device, mountpoint);
7731 /* TestOutputList for command_lines (6) */
7733 char remotefilename[] = "/test-command";
7736 r = guestfs_upload (g, "test-command", remotefilename);
7741 char path[] = "/test-command";
7744 r = guestfs_chmod (g, 493, path);
7749 char arguments_0[] = "/test-command";
7750 char arguments_1[] = "7";
7751 char *arguments[] = {
7759 r = guestfs_command_lines (g, arguments);
7763 fprintf (stderr, "test_command_lines_6: extra elements returned from command\n");
7767 for (i = 0; r[i] != NULL; ++i)
7774 static int test_command_lines_7_skip (void)
7778 str = getenv ("SKIP_TEST_COMMAND_LINES_7");
7779 if (str && strcmp (str, "1") == 0) return 1;
7780 str = getenv ("SKIP_TEST_COMMAND_LINES");
7781 if (str && strcmp (str, "1") == 0) return 1;
7785 static int test_command_lines_7 (void)
7787 if (test_command_lines_7_skip ()) {
7788 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_7");
7792 /* InitBasicFS for test_command_lines_7: create ext2 on /dev/sda1 */
7794 char device[] = "/dev/sda";
7795 device[5] = devchar;
7798 r = guestfs_blockdev_setrw (g, device);
7805 r = guestfs_umount_all (g);
7812 r = guestfs_lvm_remove_all (g);
7817 char device[] = "/dev/sda";
7818 device[5] = devchar;
7819 char lines_0[] = ",";
7826 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7831 char fstype[] = "ext2";
7832 char device[] = "/dev/sda1";
7833 device[5] = devchar;
7836 r = guestfs_mkfs (g, fstype, device);
7841 char device[] = "/dev/sda1";
7842 device[5] = devchar;
7843 char mountpoint[] = "/";
7846 r = guestfs_mount (g, device, mountpoint);
7850 /* TestOutputList for command_lines (7) */
7852 char remotefilename[] = "/test-command";
7855 r = guestfs_upload (g, "test-command", remotefilename);
7860 char path[] = "/test-command";
7863 r = guestfs_chmod (g, 493, path);
7868 char arguments_0[] = "/test-command";
7869 char arguments_1[] = "8";
7870 char *arguments[] = {
7878 r = guestfs_command_lines (g, arguments);
7882 fprintf (stderr, "test_command_lines_7: short list returned from command\n");
7887 char expected[] = "";
7888 if (strcmp (r[0], expected) != 0) {
7889 fprintf (stderr, "test_command_lines_7: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7894 fprintf (stderr, "test_command_lines_7: extra elements returned from command\n");
7898 for (i = 0; r[i] != NULL; ++i)
7905 static int test_command_lines_8_skip (void)
7909 str = getenv ("SKIP_TEST_COMMAND_LINES_8");
7910 if (str && strcmp (str, "1") == 0) return 1;
7911 str = getenv ("SKIP_TEST_COMMAND_LINES");
7912 if (str && strcmp (str, "1") == 0) return 1;
7916 static int test_command_lines_8 (void)
7918 if (test_command_lines_8_skip ()) {
7919 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_8");
7923 /* InitBasicFS for test_command_lines_8: create ext2 on /dev/sda1 */
7925 char device[] = "/dev/sda";
7926 device[5] = devchar;
7929 r = guestfs_blockdev_setrw (g, device);
7936 r = guestfs_umount_all (g);
7943 r = guestfs_lvm_remove_all (g);
7948 char device[] = "/dev/sda";
7949 device[5] = devchar;
7950 char lines_0[] = ",";
7957 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7962 char fstype[] = "ext2";
7963 char device[] = "/dev/sda1";
7964 device[5] = devchar;
7967 r = guestfs_mkfs (g, fstype, device);
7972 char device[] = "/dev/sda1";
7973 device[5] = devchar;
7974 char mountpoint[] = "/";
7977 r = guestfs_mount (g, device, mountpoint);
7981 /* TestOutputList for command_lines (8) */
7983 char remotefilename[] = "/test-command";
7986 r = guestfs_upload (g, "test-command", remotefilename);
7991 char path[] = "/test-command";
7994 r = guestfs_chmod (g, 493, path);
7999 char arguments_0[] = "/test-command";
8000 char arguments_1[] = "9";
8001 char *arguments[] = {
8009 r = guestfs_command_lines (g, arguments);
8013 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8018 char expected[] = "";
8019 if (strcmp (r[0], expected) != 0) {
8020 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8025 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8030 char expected[] = "";
8031 if (strcmp (r[1], expected) != 0) {
8032 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8037 fprintf (stderr, "test_command_lines_8: extra elements returned from command\n");
8041 for (i = 0; r[i] != NULL; ++i)
8048 static int test_command_lines_9_skip (void)
8052 str = getenv ("SKIP_TEST_COMMAND_LINES_9");
8053 if (str && strcmp (str, "1") == 0) return 1;
8054 str = getenv ("SKIP_TEST_COMMAND_LINES");
8055 if (str && strcmp (str, "1") == 0) return 1;
8059 static int test_command_lines_9 (void)
8061 if (test_command_lines_9_skip ()) {
8062 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_9");
8066 /* InitBasicFS for test_command_lines_9: create ext2 on /dev/sda1 */
8068 char device[] = "/dev/sda";
8069 device[5] = devchar;
8072 r = guestfs_blockdev_setrw (g, device);
8079 r = guestfs_umount_all (g);
8086 r = guestfs_lvm_remove_all (g);
8091 char device[] = "/dev/sda";
8092 device[5] = devchar;
8093 char lines_0[] = ",";
8100 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8105 char fstype[] = "ext2";
8106 char device[] = "/dev/sda1";
8107 device[5] = devchar;
8110 r = guestfs_mkfs (g, fstype, device);
8115 char device[] = "/dev/sda1";
8116 device[5] = devchar;
8117 char mountpoint[] = "/";
8120 r = guestfs_mount (g, device, mountpoint);
8124 /* TestOutputList for command_lines (9) */
8126 char remotefilename[] = "/test-command";
8129 r = guestfs_upload (g, "test-command", remotefilename);
8134 char path[] = "/test-command";
8137 r = guestfs_chmod (g, 493, path);
8142 char arguments_0[] = "/test-command";
8143 char arguments_1[] = "10";
8144 char *arguments[] = {
8152 r = guestfs_command_lines (g, arguments);
8156 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8161 char expected[] = "Result10-1";
8162 if (strcmp (r[0], expected) != 0) {
8163 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8168 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8173 char expected[] = "Result10-2";
8174 if (strcmp (r[1], expected) != 0) {
8175 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8180 fprintf (stderr, "test_command_lines_9: extra elements returned from command\n");
8184 for (i = 0; r[i] != NULL; ++i)
8191 static int test_command_lines_10_skip (void)
8195 str = getenv ("SKIP_TEST_COMMAND_LINES_10");
8196 if (str && strcmp (str, "1") == 0) return 1;
8197 str = getenv ("SKIP_TEST_COMMAND_LINES");
8198 if (str && strcmp (str, "1") == 0) return 1;
8202 static int test_command_lines_10 (void)
8204 if (test_command_lines_10_skip ()) {
8205 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_10");
8209 /* InitBasicFS for test_command_lines_10: create ext2 on /dev/sda1 */
8211 char device[] = "/dev/sda";
8212 device[5] = devchar;
8215 r = guestfs_blockdev_setrw (g, device);
8222 r = guestfs_umount_all (g);
8229 r = guestfs_lvm_remove_all (g);
8234 char device[] = "/dev/sda";
8235 device[5] = devchar;
8236 char lines_0[] = ",";
8243 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8248 char fstype[] = "ext2";
8249 char device[] = "/dev/sda1";
8250 device[5] = devchar;
8253 r = guestfs_mkfs (g, fstype, device);
8258 char device[] = "/dev/sda1";
8259 device[5] = devchar;
8260 char mountpoint[] = "/";
8263 r = guestfs_mount (g, device, mountpoint);
8267 /* TestOutputList for command_lines (10) */
8269 char remotefilename[] = "/test-command";
8272 r = guestfs_upload (g, "test-command", remotefilename);
8277 char path[] = "/test-command";
8280 r = guestfs_chmod (g, 493, path);
8285 char arguments_0[] = "/test-command";
8286 char arguments_1[] = "11";
8287 char *arguments[] = {
8295 r = guestfs_command_lines (g, arguments);
8299 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
8304 char expected[] = "Result11-1";
8305 if (strcmp (r[0], expected) != 0) {
8306 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8311 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
8316 char expected[] = "Result11-2";
8317 if (strcmp (r[1], expected) != 0) {
8318 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8323 fprintf (stderr, "test_command_lines_10: extra elements returned from command\n");
8327 for (i = 0; r[i] != NULL; ++i)
8334 static int test_command_0_skip (void)
8338 str = getenv ("SKIP_TEST_COMMAND_0");
8339 if (str && strcmp (str, "1") == 0) return 1;
8340 str = getenv ("SKIP_TEST_COMMAND");
8341 if (str && strcmp (str, "1") == 0) return 1;
8345 static int test_command_0 (void)
8347 if (test_command_0_skip ()) {
8348 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_0");
8352 /* InitBasicFS for test_command_0: create ext2 on /dev/sda1 */
8354 char device[] = "/dev/sda";
8355 device[5] = devchar;
8358 r = guestfs_blockdev_setrw (g, device);
8365 r = guestfs_umount_all (g);
8372 r = guestfs_lvm_remove_all (g);
8377 char device[] = "/dev/sda";
8378 device[5] = devchar;
8379 char lines_0[] = ",";
8386 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8391 char fstype[] = "ext2";
8392 char device[] = "/dev/sda1";
8393 device[5] = devchar;
8396 r = guestfs_mkfs (g, fstype, device);
8401 char device[] = "/dev/sda1";
8402 device[5] = devchar;
8403 char mountpoint[] = "/";
8406 r = guestfs_mount (g, device, mountpoint);
8410 /* TestOutput for command (0) */
8411 char expected[] = "Result1";
8413 char remotefilename[] = "/test-command";
8416 r = guestfs_upload (g, "test-command", remotefilename);
8421 char path[] = "/test-command";
8424 r = guestfs_chmod (g, 493, path);
8429 char arguments_0[] = "/test-command";
8430 char arguments_1[] = "1";
8431 char *arguments[] = {
8438 r = guestfs_command (g, arguments);
8441 if (strcmp (r, expected) != 0) {
8442 fprintf (stderr, "test_command_0: expected \"%s\" but got \"%s\"\n", expected, r);
8450 static int test_command_1_skip (void)
8454 str = getenv ("SKIP_TEST_COMMAND_1");
8455 if (str && strcmp (str, "1") == 0) return 1;
8456 str = getenv ("SKIP_TEST_COMMAND");
8457 if (str && strcmp (str, "1") == 0) return 1;
8461 static int test_command_1 (void)
8463 if (test_command_1_skip ()) {
8464 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_1");
8468 /* InitBasicFS for test_command_1: create ext2 on /dev/sda1 */
8470 char device[] = "/dev/sda";
8471 device[5] = devchar;
8474 r = guestfs_blockdev_setrw (g, device);
8481 r = guestfs_umount_all (g);
8488 r = guestfs_lvm_remove_all (g);
8493 char device[] = "/dev/sda";
8494 device[5] = devchar;
8495 char lines_0[] = ",";
8502 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8507 char fstype[] = "ext2";
8508 char device[] = "/dev/sda1";
8509 device[5] = devchar;
8512 r = guestfs_mkfs (g, fstype, device);
8517 char device[] = "/dev/sda1";
8518 device[5] = devchar;
8519 char mountpoint[] = "/";
8522 r = guestfs_mount (g, device, mountpoint);
8526 /* TestOutput for command (1) */
8527 char expected[] = "Result2\n";
8529 char remotefilename[] = "/test-command";
8532 r = guestfs_upload (g, "test-command", remotefilename);
8537 char path[] = "/test-command";
8540 r = guestfs_chmod (g, 493, path);
8545 char arguments_0[] = "/test-command";
8546 char arguments_1[] = "2";
8547 char *arguments[] = {
8554 r = guestfs_command (g, arguments);
8557 if (strcmp (r, expected) != 0) {
8558 fprintf (stderr, "test_command_1: expected \"%s\" but got \"%s\"\n", expected, r);
8566 static int test_command_2_skip (void)
8570 str = getenv ("SKIP_TEST_COMMAND_2");
8571 if (str && strcmp (str, "1") == 0) return 1;
8572 str = getenv ("SKIP_TEST_COMMAND");
8573 if (str && strcmp (str, "1") == 0) return 1;
8577 static int test_command_2 (void)
8579 if (test_command_2_skip ()) {
8580 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_2");
8584 /* InitBasicFS for test_command_2: create ext2 on /dev/sda1 */
8586 char device[] = "/dev/sda";
8587 device[5] = devchar;
8590 r = guestfs_blockdev_setrw (g, device);
8597 r = guestfs_umount_all (g);
8604 r = guestfs_lvm_remove_all (g);
8609 char device[] = "/dev/sda";
8610 device[5] = devchar;
8611 char lines_0[] = ",";
8618 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8623 char fstype[] = "ext2";
8624 char device[] = "/dev/sda1";
8625 device[5] = devchar;
8628 r = guestfs_mkfs (g, fstype, device);
8633 char device[] = "/dev/sda1";
8634 device[5] = devchar;
8635 char mountpoint[] = "/";
8638 r = guestfs_mount (g, device, mountpoint);
8642 /* TestOutput for command (2) */
8643 char expected[] = "\nResult3";
8645 char remotefilename[] = "/test-command";
8648 r = guestfs_upload (g, "test-command", remotefilename);
8653 char path[] = "/test-command";
8656 r = guestfs_chmod (g, 493, path);
8661 char arguments_0[] = "/test-command";
8662 char arguments_1[] = "3";
8663 char *arguments[] = {
8670 r = guestfs_command (g, arguments);
8673 if (strcmp (r, expected) != 0) {
8674 fprintf (stderr, "test_command_2: expected \"%s\" but got \"%s\"\n", expected, r);
8682 static int test_command_3_skip (void)
8686 str = getenv ("SKIP_TEST_COMMAND_3");
8687 if (str && strcmp (str, "1") == 0) return 1;
8688 str = getenv ("SKIP_TEST_COMMAND");
8689 if (str && strcmp (str, "1") == 0) return 1;
8693 static int test_command_3 (void)
8695 if (test_command_3_skip ()) {
8696 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_3");
8700 /* InitBasicFS for test_command_3: create ext2 on /dev/sda1 */
8702 char device[] = "/dev/sda";
8703 device[5] = devchar;
8706 r = guestfs_blockdev_setrw (g, device);
8713 r = guestfs_umount_all (g);
8720 r = guestfs_lvm_remove_all (g);
8725 char device[] = "/dev/sda";
8726 device[5] = devchar;
8727 char lines_0[] = ",";
8734 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8739 char fstype[] = "ext2";
8740 char device[] = "/dev/sda1";
8741 device[5] = devchar;
8744 r = guestfs_mkfs (g, fstype, device);
8749 char device[] = "/dev/sda1";
8750 device[5] = devchar;
8751 char mountpoint[] = "/";
8754 r = guestfs_mount (g, device, mountpoint);
8758 /* TestOutput for command (3) */
8759 char expected[] = "\nResult4\n";
8761 char remotefilename[] = "/test-command";
8764 r = guestfs_upload (g, "test-command", remotefilename);
8769 char path[] = "/test-command";
8772 r = guestfs_chmod (g, 493, path);
8777 char arguments_0[] = "/test-command";
8778 char arguments_1[] = "4";
8779 char *arguments[] = {
8786 r = guestfs_command (g, arguments);
8789 if (strcmp (r, expected) != 0) {
8790 fprintf (stderr, "test_command_3: expected \"%s\" but got \"%s\"\n", expected, r);
8798 static int test_command_4_skip (void)
8802 str = getenv ("SKIP_TEST_COMMAND_4");
8803 if (str && strcmp (str, "1") == 0) return 1;
8804 str = getenv ("SKIP_TEST_COMMAND");
8805 if (str && strcmp (str, "1") == 0) return 1;
8809 static int test_command_4 (void)
8811 if (test_command_4_skip ()) {
8812 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_4");
8816 /* InitBasicFS for test_command_4: create ext2 on /dev/sda1 */
8818 char device[] = "/dev/sda";
8819 device[5] = devchar;
8822 r = guestfs_blockdev_setrw (g, device);
8829 r = guestfs_umount_all (g);
8836 r = guestfs_lvm_remove_all (g);
8841 char device[] = "/dev/sda";
8842 device[5] = devchar;
8843 char lines_0[] = ",";
8850 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8855 char fstype[] = "ext2";
8856 char device[] = "/dev/sda1";
8857 device[5] = devchar;
8860 r = guestfs_mkfs (g, fstype, device);
8865 char device[] = "/dev/sda1";
8866 device[5] = devchar;
8867 char mountpoint[] = "/";
8870 r = guestfs_mount (g, device, mountpoint);
8874 /* TestOutput for command (4) */
8875 char expected[] = "\nResult5\n\n";
8877 char remotefilename[] = "/test-command";
8880 r = guestfs_upload (g, "test-command", remotefilename);
8885 char path[] = "/test-command";
8888 r = guestfs_chmod (g, 493, path);
8893 char arguments_0[] = "/test-command";
8894 char arguments_1[] = "5";
8895 char *arguments[] = {
8902 r = guestfs_command (g, arguments);
8905 if (strcmp (r, expected) != 0) {
8906 fprintf (stderr, "test_command_4: expected \"%s\" but got \"%s\"\n", expected, r);
8914 static int test_command_5_skip (void)
8918 str = getenv ("SKIP_TEST_COMMAND_5");
8919 if (str && strcmp (str, "1") == 0) return 1;
8920 str = getenv ("SKIP_TEST_COMMAND");
8921 if (str && strcmp (str, "1") == 0) return 1;
8925 static int test_command_5 (void)
8927 if (test_command_5_skip ()) {
8928 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_5");
8932 /* InitBasicFS for test_command_5: create ext2 on /dev/sda1 */
8934 char device[] = "/dev/sda";
8935 device[5] = devchar;
8938 r = guestfs_blockdev_setrw (g, device);
8945 r = guestfs_umount_all (g);
8952 r = guestfs_lvm_remove_all (g);
8957 char device[] = "/dev/sda";
8958 device[5] = devchar;
8959 char lines_0[] = ",";
8966 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8971 char fstype[] = "ext2";
8972 char device[] = "/dev/sda1";
8973 device[5] = devchar;
8976 r = guestfs_mkfs (g, fstype, device);
8981 char device[] = "/dev/sda1";
8982 device[5] = devchar;
8983 char mountpoint[] = "/";
8986 r = guestfs_mount (g, device, mountpoint);
8990 /* TestOutput for command (5) */
8991 char expected[] = "\n\nResult6\n\n";
8993 char remotefilename[] = "/test-command";
8996 r = guestfs_upload (g, "test-command", remotefilename);
9001 char path[] = "/test-command";
9004 r = guestfs_chmod (g, 493, path);
9009 char arguments_0[] = "/test-command";
9010 char arguments_1[] = "6";
9011 char *arguments[] = {
9018 r = guestfs_command (g, arguments);
9021 if (strcmp (r, expected) != 0) {
9022 fprintf (stderr, "test_command_5: expected \"%s\" but got \"%s\"\n", expected, r);
9030 static int test_command_6_skip (void)
9034 str = getenv ("SKIP_TEST_COMMAND_6");
9035 if (str && strcmp (str, "1") == 0) return 1;
9036 str = getenv ("SKIP_TEST_COMMAND");
9037 if (str && strcmp (str, "1") == 0) return 1;
9041 static int test_command_6 (void)
9043 if (test_command_6_skip ()) {
9044 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_6");
9048 /* InitBasicFS for test_command_6: create ext2 on /dev/sda1 */
9050 char device[] = "/dev/sda";
9051 device[5] = devchar;
9054 r = guestfs_blockdev_setrw (g, device);
9061 r = guestfs_umount_all (g);
9068 r = guestfs_lvm_remove_all (g);
9073 char device[] = "/dev/sda";
9074 device[5] = devchar;
9075 char lines_0[] = ",";
9082 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9087 char fstype[] = "ext2";
9088 char device[] = "/dev/sda1";
9089 device[5] = devchar;
9092 r = guestfs_mkfs (g, fstype, device);
9097 char device[] = "/dev/sda1";
9098 device[5] = devchar;
9099 char mountpoint[] = "/";
9102 r = guestfs_mount (g, device, mountpoint);
9106 /* TestOutput for command (6) */
9107 char expected[] = "";
9109 char remotefilename[] = "/test-command";
9112 r = guestfs_upload (g, "test-command", remotefilename);
9117 char path[] = "/test-command";
9120 r = guestfs_chmod (g, 493, path);
9125 char arguments_0[] = "/test-command";
9126 char arguments_1[] = "7";
9127 char *arguments[] = {
9134 r = guestfs_command (g, arguments);
9137 if (strcmp (r, expected) != 0) {
9138 fprintf (stderr, "test_command_6: expected \"%s\" but got \"%s\"\n", expected, r);
9146 static int test_command_7_skip (void)
9150 str = getenv ("SKIP_TEST_COMMAND_7");
9151 if (str && strcmp (str, "1") == 0) return 1;
9152 str = getenv ("SKIP_TEST_COMMAND");
9153 if (str && strcmp (str, "1") == 0) return 1;
9157 static int test_command_7 (void)
9159 if (test_command_7_skip ()) {
9160 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_7");
9164 /* InitBasicFS for test_command_7: create ext2 on /dev/sda1 */
9166 char device[] = "/dev/sda";
9167 device[5] = devchar;
9170 r = guestfs_blockdev_setrw (g, device);
9177 r = guestfs_umount_all (g);
9184 r = guestfs_lvm_remove_all (g);
9189 char device[] = "/dev/sda";
9190 device[5] = devchar;
9191 char lines_0[] = ",";
9198 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9203 char fstype[] = "ext2";
9204 char device[] = "/dev/sda1";
9205 device[5] = devchar;
9208 r = guestfs_mkfs (g, fstype, device);
9213 char device[] = "/dev/sda1";
9214 device[5] = devchar;
9215 char mountpoint[] = "/";
9218 r = guestfs_mount (g, device, mountpoint);
9222 /* TestOutput for command (7) */
9223 char expected[] = "\n";
9225 char remotefilename[] = "/test-command";
9228 r = guestfs_upload (g, "test-command", remotefilename);
9233 char path[] = "/test-command";
9236 r = guestfs_chmod (g, 493, path);
9241 char arguments_0[] = "/test-command";
9242 char arguments_1[] = "8";
9243 char *arguments[] = {
9250 r = guestfs_command (g, arguments);
9253 if (strcmp (r, expected) != 0) {
9254 fprintf (stderr, "test_command_7: expected \"%s\" but got \"%s\"\n", expected, r);
9262 static int test_command_8_skip (void)
9266 str = getenv ("SKIP_TEST_COMMAND_8");
9267 if (str && strcmp (str, "1") == 0) return 1;
9268 str = getenv ("SKIP_TEST_COMMAND");
9269 if (str && strcmp (str, "1") == 0) return 1;
9273 static int test_command_8 (void)
9275 if (test_command_8_skip ()) {
9276 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_8");
9280 /* InitBasicFS for test_command_8: create ext2 on /dev/sda1 */
9282 char device[] = "/dev/sda";
9283 device[5] = devchar;
9286 r = guestfs_blockdev_setrw (g, device);
9293 r = guestfs_umount_all (g);
9300 r = guestfs_lvm_remove_all (g);
9305 char device[] = "/dev/sda";
9306 device[5] = devchar;
9307 char lines_0[] = ",";
9314 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9319 char fstype[] = "ext2";
9320 char device[] = "/dev/sda1";
9321 device[5] = devchar;
9324 r = guestfs_mkfs (g, fstype, device);
9329 char device[] = "/dev/sda1";
9330 device[5] = devchar;
9331 char mountpoint[] = "/";
9334 r = guestfs_mount (g, device, mountpoint);
9338 /* TestOutput for command (8) */
9339 char expected[] = "\n\n";
9341 char remotefilename[] = "/test-command";
9344 r = guestfs_upload (g, "test-command", remotefilename);
9349 char path[] = "/test-command";
9352 r = guestfs_chmod (g, 493, path);
9357 char arguments_0[] = "/test-command";
9358 char arguments_1[] = "9";
9359 char *arguments[] = {
9366 r = guestfs_command (g, arguments);
9369 if (strcmp (r, expected) != 0) {
9370 fprintf (stderr, "test_command_8: expected \"%s\" but got \"%s\"\n", expected, r);
9378 static int test_command_9_skip (void)
9382 str = getenv ("SKIP_TEST_COMMAND_9");
9383 if (str && strcmp (str, "1") == 0) return 1;
9384 str = getenv ("SKIP_TEST_COMMAND");
9385 if (str && strcmp (str, "1") == 0) return 1;
9389 static int test_command_9 (void)
9391 if (test_command_9_skip ()) {
9392 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_9");
9396 /* InitBasicFS for test_command_9: create ext2 on /dev/sda1 */
9398 char device[] = "/dev/sda";
9399 device[5] = devchar;
9402 r = guestfs_blockdev_setrw (g, device);
9409 r = guestfs_umount_all (g);
9416 r = guestfs_lvm_remove_all (g);
9421 char device[] = "/dev/sda";
9422 device[5] = devchar;
9423 char lines_0[] = ",";
9430 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9435 char fstype[] = "ext2";
9436 char device[] = "/dev/sda1";
9437 device[5] = devchar;
9440 r = guestfs_mkfs (g, fstype, device);
9445 char device[] = "/dev/sda1";
9446 device[5] = devchar;
9447 char mountpoint[] = "/";
9450 r = guestfs_mount (g, device, mountpoint);
9454 /* TestOutput for command (9) */
9455 char expected[] = "Result10-1\nResult10-2\n";
9457 char remotefilename[] = "/test-command";
9460 r = guestfs_upload (g, "test-command", remotefilename);
9465 char path[] = "/test-command";
9468 r = guestfs_chmod (g, 493, path);
9473 char arguments_0[] = "/test-command";
9474 char arguments_1[] = "10";
9475 char *arguments[] = {
9482 r = guestfs_command (g, arguments);
9485 if (strcmp (r, expected) != 0) {
9486 fprintf (stderr, "test_command_9: expected \"%s\" but got \"%s\"\n", expected, r);
9494 static int test_command_10_skip (void)
9498 str = getenv ("SKIP_TEST_COMMAND_10");
9499 if (str && strcmp (str, "1") == 0) return 1;
9500 str = getenv ("SKIP_TEST_COMMAND");
9501 if (str && strcmp (str, "1") == 0) return 1;
9505 static int test_command_10 (void)
9507 if (test_command_10_skip ()) {
9508 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_10");
9512 /* InitBasicFS for test_command_10: create ext2 on /dev/sda1 */
9514 char device[] = "/dev/sda";
9515 device[5] = devchar;
9518 r = guestfs_blockdev_setrw (g, device);
9525 r = guestfs_umount_all (g);
9532 r = guestfs_lvm_remove_all (g);
9537 char device[] = "/dev/sda";
9538 device[5] = devchar;
9539 char lines_0[] = ",";
9546 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9551 char fstype[] = "ext2";
9552 char device[] = "/dev/sda1";
9553 device[5] = devchar;
9556 r = guestfs_mkfs (g, fstype, device);
9561 char device[] = "/dev/sda1";
9562 device[5] = devchar;
9563 char mountpoint[] = "/";
9566 r = guestfs_mount (g, device, mountpoint);
9570 /* TestOutput for command (10) */
9571 char expected[] = "Result11-1\nResult11-2";
9573 char remotefilename[] = "/test-command";
9576 r = guestfs_upload (g, "test-command", remotefilename);
9581 char path[] = "/test-command";
9584 r = guestfs_chmod (g, 493, path);
9589 char arguments_0[] = "/test-command";
9590 char arguments_1[] = "11";
9591 char *arguments[] = {
9598 r = guestfs_command (g, arguments);
9601 if (strcmp (r, expected) != 0) {
9602 fprintf (stderr, "test_command_10: expected \"%s\" but got \"%s\"\n", expected, r);
9610 static int test_command_11_skip (void)
9614 str = getenv ("SKIP_TEST_COMMAND_11");
9615 if (str && strcmp (str, "1") == 0) return 1;
9616 str = getenv ("SKIP_TEST_COMMAND");
9617 if (str && strcmp (str, "1") == 0) return 1;
9621 static int test_command_11 (void)
9623 if (test_command_11_skip ()) {
9624 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_11");
9628 /* InitBasicFS for test_command_11: create ext2 on /dev/sda1 */
9630 char device[] = "/dev/sda";
9631 device[5] = devchar;
9634 r = guestfs_blockdev_setrw (g, device);
9641 r = guestfs_umount_all (g);
9648 r = guestfs_lvm_remove_all (g);
9653 char device[] = "/dev/sda";
9654 device[5] = devchar;
9655 char lines_0[] = ",";
9662 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9667 char fstype[] = "ext2";
9668 char device[] = "/dev/sda1";
9669 device[5] = devchar;
9672 r = guestfs_mkfs (g, fstype, device);
9677 char device[] = "/dev/sda1";
9678 device[5] = devchar;
9679 char mountpoint[] = "/";
9682 r = guestfs_mount (g, device, mountpoint);
9686 /* TestLastFail for command (11) */
9688 char remotefilename[] = "/test-command";
9691 r = guestfs_upload (g, "test-command", remotefilename);
9696 char path[] = "/test-command";
9699 r = guestfs_chmod (g, 493, path);
9704 char arguments_0[] = "/test-command";
9705 char *arguments[] = {
9711 r = guestfs_command (g, arguments);
9719 static int test_file_0_skip (void)
9723 str = getenv ("SKIP_TEST_FILE_0");
9724 if (str && strcmp (str, "1") == 0) return 1;
9725 str = getenv ("SKIP_TEST_FILE");
9726 if (str && strcmp (str, "1") == 0) return 1;
9730 static int test_file_0 (void)
9732 if (test_file_0_skip ()) {
9733 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_0");
9737 /* InitBasicFS for test_file_0: create ext2 on /dev/sda1 */
9739 char device[] = "/dev/sda";
9740 device[5] = devchar;
9743 r = guestfs_blockdev_setrw (g, device);
9750 r = guestfs_umount_all (g);
9757 r = guestfs_lvm_remove_all (g);
9762 char device[] = "/dev/sda";
9763 device[5] = devchar;
9764 char lines_0[] = ",";
9771 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9776 char fstype[] = "ext2";
9777 char device[] = "/dev/sda1";
9778 device[5] = devchar;
9781 r = guestfs_mkfs (g, fstype, device);
9786 char device[] = "/dev/sda1";
9787 device[5] = devchar;
9788 char mountpoint[] = "/";
9791 r = guestfs_mount (g, device, mountpoint);
9795 /* TestOutput for file (0) */
9796 char expected[] = "empty";
9798 char path[] = "/new";
9801 r = guestfs_touch (g, path);
9806 char path[] = "/new";
9809 r = guestfs_file (g, path);
9812 if (strcmp (r, expected) != 0) {
9813 fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
9821 static int test_file_1_skip (void)
9825 str = getenv ("SKIP_TEST_FILE_1");
9826 if (str && strcmp (str, "1") == 0) return 1;
9827 str = getenv ("SKIP_TEST_FILE");
9828 if (str && strcmp (str, "1") == 0) return 1;
9832 static int test_file_1 (void)
9834 if (test_file_1_skip ()) {
9835 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_1");
9839 /* InitBasicFS for test_file_1: create ext2 on /dev/sda1 */
9841 char device[] = "/dev/sda";
9842 device[5] = devchar;
9845 r = guestfs_blockdev_setrw (g, device);
9852 r = guestfs_umount_all (g);
9859 r = guestfs_lvm_remove_all (g);
9864 char device[] = "/dev/sda";
9865 device[5] = devchar;
9866 char lines_0[] = ",";
9873 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9878 char fstype[] = "ext2";
9879 char device[] = "/dev/sda1";
9880 device[5] = devchar;
9883 r = guestfs_mkfs (g, fstype, device);
9888 char device[] = "/dev/sda1";
9889 device[5] = devchar;
9890 char mountpoint[] = "/";
9893 r = guestfs_mount (g, device, mountpoint);
9897 /* TestOutput for file (1) */
9898 char expected[] = "ASCII text";
9900 char path[] = "/new";
9901 char content[] = "some content\n";
9904 r = guestfs_write_file (g, path, content, 0);
9909 char path[] = "/new";
9912 r = guestfs_file (g, path);
9915 if (strcmp (r, expected) != 0) {
9916 fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
9924 static int test_file_2_skip (void)
9928 str = getenv ("SKIP_TEST_FILE_2");
9929 if (str && strcmp (str, "1") == 0) return 1;
9930 str = getenv ("SKIP_TEST_FILE");
9931 if (str && strcmp (str, "1") == 0) return 1;
9935 static int test_file_2 (void)
9937 if (test_file_2_skip ()) {
9938 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_2");
9942 /* InitBasicFS for test_file_2: create ext2 on /dev/sda1 */
9944 char device[] = "/dev/sda";
9945 device[5] = devchar;
9948 r = guestfs_blockdev_setrw (g, device);
9955 r = guestfs_umount_all (g);
9962 r = guestfs_lvm_remove_all (g);
9967 char device[] = "/dev/sda";
9968 device[5] = devchar;
9969 char lines_0[] = ",";
9976 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9981 char fstype[] = "ext2";
9982 char device[] = "/dev/sda1";
9983 device[5] = devchar;
9986 r = guestfs_mkfs (g, fstype, device);
9991 char device[] = "/dev/sda1";
9992 device[5] = devchar;
9993 char mountpoint[] = "/";
9996 r = guestfs_mount (g, device, mountpoint);
10000 /* TestLastFail for file (2) */
10002 char path[] = "/nofile";
10004 suppress_error = 1;
10005 r = guestfs_file (g, path);
10013 static int test_umount_all_0_skip (void)
10017 str = getenv ("SKIP_TEST_UMOUNT_ALL_0");
10018 if (str && strcmp (str, "1") == 0) return 1;
10019 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10020 if (str && strcmp (str, "1") == 0) return 1;
10024 static int test_umount_all_0 (void)
10026 if (test_umount_all_0_skip ()) {
10027 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_0");
10031 /* InitBasicFS for test_umount_all_0: create ext2 on /dev/sda1 */
10033 char device[] = "/dev/sda";
10034 device[5] = devchar;
10036 suppress_error = 0;
10037 r = guestfs_blockdev_setrw (g, device);
10043 suppress_error = 0;
10044 r = guestfs_umount_all (g);
10050 suppress_error = 0;
10051 r = guestfs_lvm_remove_all (g);
10056 char device[] = "/dev/sda";
10057 device[5] = devchar;
10058 char lines_0[] = ",";
10064 suppress_error = 0;
10065 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10070 char fstype[] = "ext2";
10071 char device[] = "/dev/sda1";
10072 device[5] = devchar;
10074 suppress_error = 0;
10075 r = guestfs_mkfs (g, fstype, device);
10080 char device[] = "/dev/sda1";
10081 device[5] = devchar;
10082 char mountpoint[] = "/";
10084 suppress_error = 0;
10085 r = guestfs_mount (g, device, mountpoint);
10089 /* TestOutputList for umount_all (0) */
10092 suppress_error = 0;
10093 r = guestfs_umount_all (g);
10100 suppress_error = 0;
10101 r = guestfs_mounts (g);
10104 if (r[0] != NULL) {
10105 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
10109 for (i = 0; r[i] != NULL; ++i)
10116 static int test_umount_all_1_skip (void)
10120 str = getenv ("SKIP_TEST_UMOUNT_ALL_1");
10121 if (str && strcmp (str, "1") == 0) return 1;
10122 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10123 if (str && strcmp (str, "1") == 0) return 1;
10127 static int test_umount_all_1 (void)
10129 if (test_umount_all_1_skip ()) {
10130 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_1");
10134 /* InitNone|InitEmpty for test_umount_all_1 */
10136 char device[] = "/dev/sda";
10137 device[5] = devchar;
10139 suppress_error = 0;
10140 r = guestfs_blockdev_setrw (g, device);
10146 suppress_error = 0;
10147 r = guestfs_umount_all (g);
10153 suppress_error = 0;
10154 r = guestfs_lvm_remove_all (g);
10158 /* TestOutputList for umount_all (1) */
10160 char device[] = "/dev/sda";
10161 device[5] = devchar;
10162 char lines_0[] = ",10";
10163 char lines_1[] = ",20";
10164 char lines_2[] = ",";
10172 suppress_error = 0;
10173 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10178 char fstype[] = "ext2";
10179 char device[] = "/dev/sda1";
10180 device[5] = devchar;
10182 suppress_error = 0;
10183 r = guestfs_mkfs (g, fstype, device);
10188 char fstype[] = "ext2";
10189 char device[] = "/dev/sda2";
10190 device[5] = devchar;
10192 suppress_error = 0;
10193 r = guestfs_mkfs (g, fstype, device);
10198 char fstype[] = "ext2";
10199 char device[] = "/dev/sda3";
10200 device[5] = devchar;
10202 suppress_error = 0;
10203 r = guestfs_mkfs (g, fstype, device);
10208 char device[] = "/dev/sda1";
10209 device[5] = devchar;
10210 char mountpoint[] = "/";
10212 suppress_error = 0;
10213 r = guestfs_mount (g, device, mountpoint);
10218 char path[] = "/mp1";
10220 suppress_error = 0;
10221 r = guestfs_mkdir (g, path);
10226 char device[] = "/dev/sda2";
10227 device[5] = devchar;
10228 char mountpoint[] = "/mp1";
10230 suppress_error = 0;
10231 r = guestfs_mount (g, device, mountpoint);
10236 char path[] = "/mp1/mp2";
10238 suppress_error = 0;
10239 r = guestfs_mkdir (g, path);
10244 char device[] = "/dev/sda3";
10245 device[5] = devchar;
10246 char mountpoint[] = "/mp1/mp2";
10248 suppress_error = 0;
10249 r = guestfs_mount (g, device, mountpoint);
10254 char path[] = "/mp1/mp2/mp3";
10256 suppress_error = 0;
10257 r = guestfs_mkdir (g, path);
10263 suppress_error = 0;
10264 r = guestfs_umount_all (g);
10271 suppress_error = 0;
10272 r = guestfs_mounts (g);
10275 if (r[0] != NULL) {
10276 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
10280 for (i = 0; r[i] != NULL; ++i)
10287 static int test_mounts_0_skip (void)
10291 str = getenv ("SKIP_TEST_MOUNTS_0");
10292 if (str && strcmp (str, "1") == 0) return 1;
10293 str = getenv ("SKIP_TEST_MOUNTS");
10294 if (str && strcmp (str, "1") == 0) return 1;
10298 static int test_mounts_0 (void)
10300 if (test_mounts_0_skip ()) {
10301 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mounts_0");
10305 /* InitBasicFS for test_mounts_0: create ext2 on /dev/sda1 */
10307 char device[] = "/dev/sda";
10308 device[5] = devchar;
10310 suppress_error = 0;
10311 r = guestfs_blockdev_setrw (g, device);
10317 suppress_error = 0;
10318 r = guestfs_umount_all (g);
10324 suppress_error = 0;
10325 r = guestfs_lvm_remove_all (g);
10330 char device[] = "/dev/sda";
10331 device[5] = devchar;
10332 char lines_0[] = ",";
10338 suppress_error = 0;
10339 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10344 char fstype[] = "ext2";
10345 char device[] = "/dev/sda1";
10346 device[5] = devchar;
10348 suppress_error = 0;
10349 r = guestfs_mkfs (g, fstype, device);
10354 char device[] = "/dev/sda1";
10355 device[5] = devchar;
10356 char mountpoint[] = "/";
10358 suppress_error = 0;
10359 r = guestfs_mount (g, device, mountpoint);
10363 /* TestOutputList for mounts (0) */
10367 suppress_error = 0;
10368 r = guestfs_mounts (g);
10372 fprintf (stderr, "test_mounts_0: short list returned from command\n");
10377 char expected[] = "/dev/sda1";
10378 expected[5] = devchar;
10379 if (strcmp (r[0], expected) != 0) {
10380 fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
10384 if (r[1] != NULL) {
10385 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
10389 for (i = 0; r[i] != NULL; ++i)
10396 static int test_umount_0_skip (void)
10400 str = getenv ("SKIP_TEST_UMOUNT_0");
10401 if (str && strcmp (str, "1") == 0) return 1;
10402 str = getenv ("SKIP_TEST_UMOUNT");
10403 if (str && strcmp (str, "1") == 0) return 1;
10407 static int test_umount_0 (void)
10409 if (test_umount_0_skip ()) {
10410 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_0");
10414 /* InitNone|InitEmpty for test_umount_0 */
10416 char device[] = "/dev/sda";
10417 device[5] = devchar;
10419 suppress_error = 0;
10420 r = guestfs_blockdev_setrw (g, device);
10426 suppress_error = 0;
10427 r = guestfs_umount_all (g);
10433 suppress_error = 0;
10434 r = guestfs_lvm_remove_all (g);
10438 /* TestOutputList for umount (0) */
10440 char device[] = "/dev/sda";
10441 device[5] = devchar;
10442 char lines_0[] = ",";
10448 suppress_error = 0;
10449 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10454 char fstype[] = "ext2";
10455 char device[] = "/dev/sda1";
10456 device[5] = devchar;
10458 suppress_error = 0;
10459 r = guestfs_mkfs (g, fstype, device);
10464 char device[] = "/dev/sda1";
10465 device[5] = devchar;
10466 char mountpoint[] = "/";
10468 suppress_error = 0;
10469 r = guestfs_mount (g, device, mountpoint);
10476 suppress_error = 0;
10477 r = guestfs_mounts (g);
10481 fprintf (stderr, "test_umount_0: short list returned from command\n");
10486 char expected[] = "/dev/sda1";
10487 expected[5] = devchar;
10488 if (strcmp (r[0], expected) != 0) {
10489 fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
10493 if (r[1] != NULL) {
10494 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
10498 for (i = 0; r[i] != NULL; ++i)
10505 static int test_umount_1_skip (void)
10509 str = getenv ("SKIP_TEST_UMOUNT_1");
10510 if (str && strcmp (str, "1") == 0) return 1;
10511 str = getenv ("SKIP_TEST_UMOUNT");
10512 if (str && strcmp (str, "1") == 0) return 1;
10516 static int test_umount_1 (void)
10518 if (test_umount_1_skip ()) {
10519 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_1");
10523 /* InitNone|InitEmpty for test_umount_1 */
10525 char device[] = "/dev/sda";
10526 device[5] = devchar;
10528 suppress_error = 0;
10529 r = guestfs_blockdev_setrw (g, device);
10535 suppress_error = 0;
10536 r = guestfs_umount_all (g);
10542 suppress_error = 0;
10543 r = guestfs_lvm_remove_all (g);
10547 /* TestOutputList for umount (1) */
10549 char device[] = "/dev/sda";
10550 device[5] = devchar;
10551 char lines_0[] = ",";
10557 suppress_error = 0;
10558 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10563 char fstype[] = "ext2";
10564 char device[] = "/dev/sda1";
10565 device[5] = devchar;
10567 suppress_error = 0;
10568 r = guestfs_mkfs (g, fstype, device);
10573 char device[] = "/dev/sda1";
10574 device[5] = devchar;
10575 char mountpoint[] = "/";
10577 suppress_error = 0;
10578 r = guestfs_mount (g, device, mountpoint);
10583 char pathordevice[] = "/";
10585 suppress_error = 0;
10586 r = guestfs_umount (g, pathordevice);
10593 suppress_error = 0;
10594 r = guestfs_mounts (g);
10597 if (r[0] != NULL) {
10598 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
10602 for (i = 0; r[i] != NULL; ++i)
10609 static int test_write_file_0_skip (void)
10613 str = getenv ("SKIP_TEST_WRITE_FILE_0");
10614 if (str && strcmp (str, "1") == 0) return 1;
10615 str = getenv ("SKIP_TEST_WRITE_FILE");
10616 if (str && strcmp (str, "1") == 0) return 1;
10620 static int test_write_file_0 (void)
10622 if (test_write_file_0_skip ()) {
10623 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_0");
10627 /* InitBasicFS for test_write_file_0: create ext2 on /dev/sda1 */
10629 char device[] = "/dev/sda";
10630 device[5] = devchar;
10632 suppress_error = 0;
10633 r = guestfs_blockdev_setrw (g, device);
10639 suppress_error = 0;
10640 r = guestfs_umount_all (g);
10646 suppress_error = 0;
10647 r = guestfs_lvm_remove_all (g);
10652 char device[] = "/dev/sda";
10653 device[5] = devchar;
10654 char lines_0[] = ",";
10660 suppress_error = 0;
10661 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10666 char fstype[] = "ext2";
10667 char device[] = "/dev/sda1";
10668 device[5] = devchar;
10670 suppress_error = 0;
10671 r = guestfs_mkfs (g, fstype, device);
10676 char device[] = "/dev/sda1";
10677 device[5] = devchar;
10678 char mountpoint[] = "/";
10680 suppress_error = 0;
10681 r = guestfs_mount (g, device, mountpoint);
10685 /* TestOutput for write_file (0) */
10686 char expected[] = "new file contents";
10688 char path[] = "/new";
10689 char content[] = "new file contents";
10691 suppress_error = 0;
10692 r = guestfs_write_file (g, path, content, 0);
10697 char path[] = "/new";
10699 suppress_error = 0;
10700 r = guestfs_cat (g, path);
10703 if (strcmp (r, expected) != 0) {
10704 fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
10712 static int test_write_file_1_skip (void)
10716 str = getenv ("SKIP_TEST_WRITE_FILE_1");
10717 if (str && strcmp (str, "1") == 0) return 1;
10718 str = getenv ("SKIP_TEST_WRITE_FILE");
10719 if (str && strcmp (str, "1") == 0) return 1;
10723 static int test_write_file_1 (void)
10725 if (test_write_file_1_skip ()) {
10726 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_1");
10730 /* InitBasicFS for test_write_file_1: create ext2 on /dev/sda1 */
10732 char device[] = "/dev/sda";
10733 device[5] = devchar;
10735 suppress_error = 0;
10736 r = guestfs_blockdev_setrw (g, device);
10742 suppress_error = 0;
10743 r = guestfs_umount_all (g);
10749 suppress_error = 0;
10750 r = guestfs_lvm_remove_all (g);
10755 char device[] = "/dev/sda";
10756 device[5] = devchar;
10757 char lines_0[] = ",";
10763 suppress_error = 0;
10764 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10769 char fstype[] = "ext2";
10770 char device[] = "/dev/sda1";
10771 device[5] = devchar;
10773 suppress_error = 0;
10774 r = guestfs_mkfs (g, fstype, device);
10779 char device[] = "/dev/sda1";
10780 device[5] = devchar;
10781 char mountpoint[] = "/";
10783 suppress_error = 0;
10784 r = guestfs_mount (g, device, mountpoint);
10788 /* TestOutput for write_file (1) */
10789 char expected[] = "\nnew file contents\n";
10791 char path[] = "/new";
10792 char content[] = "\nnew file contents\n";
10794 suppress_error = 0;
10795 r = guestfs_write_file (g, path, content, 0);
10800 char path[] = "/new";
10802 suppress_error = 0;
10803 r = guestfs_cat (g, path);
10806 if (strcmp (r, expected) != 0) {
10807 fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
10815 static int test_write_file_2_skip (void)
10819 str = getenv ("SKIP_TEST_WRITE_FILE_2");
10820 if (str && strcmp (str, "1") == 0) return 1;
10821 str = getenv ("SKIP_TEST_WRITE_FILE");
10822 if (str && strcmp (str, "1") == 0) return 1;
10826 static int test_write_file_2 (void)
10828 if (test_write_file_2_skip ()) {
10829 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_2");
10833 /* InitBasicFS for test_write_file_2: create ext2 on /dev/sda1 */
10835 char device[] = "/dev/sda";
10836 device[5] = devchar;
10838 suppress_error = 0;
10839 r = guestfs_blockdev_setrw (g, device);
10845 suppress_error = 0;
10846 r = guestfs_umount_all (g);
10852 suppress_error = 0;
10853 r = guestfs_lvm_remove_all (g);
10858 char device[] = "/dev/sda";
10859 device[5] = devchar;
10860 char lines_0[] = ",";
10866 suppress_error = 0;
10867 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10872 char fstype[] = "ext2";
10873 char device[] = "/dev/sda1";
10874 device[5] = devchar;
10876 suppress_error = 0;
10877 r = guestfs_mkfs (g, fstype, device);
10882 char device[] = "/dev/sda1";
10883 device[5] = devchar;
10884 char mountpoint[] = "/";
10886 suppress_error = 0;
10887 r = guestfs_mount (g, device, mountpoint);
10891 /* TestOutput for write_file (2) */
10892 char expected[] = "\n\n";
10894 char path[] = "/new";
10895 char content[] = "\n\n";
10897 suppress_error = 0;
10898 r = guestfs_write_file (g, path, content, 0);
10903 char path[] = "/new";
10905 suppress_error = 0;
10906 r = guestfs_cat (g, path);
10909 if (strcmp (r, expected) != 0) {
10910 fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
10918 static int test_write_file_3_skip (void)
10922 str = getenv ("SKIP_TEST_WRITE_FILE_3");
10923 if (str && strcmp (str, "1") == 0) return 1;
10924 str = getenv ("SKIP_TEST_WRITE_FILE");
10925 if (str && strcmp (str, "1") == 0) return 1;
10929 static int test_write_file_3 (void)
10931 if (test_write_file_3_skip ()) {
10932 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_3");
10936 /* InitBasicFS for test_write_file_3: create ext2 on /dev/sda1 */
10938 char device[] = "/dev/sda";
10939 device[5] = devchar;
10941 suppress_error = 0;
10942 r = guestfs_blockdev_setrw (g, device);
10948 suppress_error = 0;
10949 r = guestfs_umount_all (g);
10955 suppress_error = 0;
10956 r = guestfs_lvm_remove_all (g);
10961 char device[] = "/dev/sda";
10962 device[5] = devchar;
10963 char lines_0[] = ",";
10969 suppress_error = 0;
10970 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10975 char fstype[] = "ext2";
10976 char device[] = "/dev/sda1";
10977 device[5] = devchar;
10979 suppress_error = 0;
10980 r = guestfs_mkfs (g, fstype, device);
10985 char device[] = "/dev/sda1";
10986 device[5] = devchar;
10987 char mountpoint[] = "/";
10989 suppress_error = 0;
10990 r = guestfs_mount (g, device, mountpoint);
10994 /* TestOutput for write_file (3) */
10995 char expected[] = "";
10997 char path[] = "/new";
10998 char content[] = "";
11000 suppress_error = 0;
11001 r = guestfs_write_file (g, path, content, 0);
11006 char path[] = "/new";
11008 suppress_error = 0;
11009 r = guestfs_cat (g, path);
11012 if (strcmp (r, expected) != 0) {
11013 fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
11021 static int test_write_file_4_skip (void)
11025 str = getenv ("SKIP_TEST_WRITE_FILE_4");
11026 if (str && strcmp (str, "1") == 0) return 1;
11027 str = getenv ("SKIP_TEST_WRITE_FILE");
11028 if (str && strcmp (str, "1") == 0) return 1;
11032 static int test_write_file_4 (void)
11034 if (test_write_file_4_skip ()) {
11035 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_4");
11039 /* InitBasicFS for test_write_file_4: create ext2 on /dev/sda1 */
11041 char device[] = "/dev/sda";
11042 device[5] = devchar;
11044 suppress_error = 0;
11045 r = guestfs_blockdev_setrw (g, device);
11051 suppress_error = 0;
11052 r = guestfs_umount_all (g);
11058 suppress_error = 0;
11059 r = guestfs_lvm_remove_all (g);
11064 char device[] = "/dev/sda";
11065 device[5] = devchar;
11066 char lines_0[] = ",";
11072 suppress_error = 0;
11073 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11078 char fstype[] = "ext2";
11079 char device[] = "/dev/sda1";
11080 device[5] = devchar;
11082 suppress_error = 0;
11083 r = guestfs_mkfs (g, fstype, device);
11088 char device[] = "/dev/sda1";
11089 device[5] = devchar;
11090 char mountpoint[] = "/";
11092 suppress_error = 0;
11093 r = guestfs_mount (g, device, mountpoint);
11097 /* TestOutput for write_file (4) */
11098 char expected[] = "\n\n\n";
11100 char path[] = "/new";
11101 char content[] = "\n\n\n";
11103 suppress_error = 0;
11104 r = guestfs_write_file (g, path, content, 0);
11109 char path[] = "/new";
11111 suppress_error = 0;
11112 r = guestfs_cat (g, path);
11115 if (strcmp (r, expected) != 0) {
11116 fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
11124 static int test_write_file_5_skip (void)
11128 str = getenv ("SKIP_TEST_WRITE_FILE_5");
11129 if (str && strcmp (str, "1") == 0) return 1;
11130 str = getenv ("SKIP_TEST_WRITE_FILE");
11131 if (str && strcmp (str, "1") == 0) return 1;
11135 static int test_write_file_5 (void)
11137 if (test_write_file_5_skip ()) {
11138 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_5");
11142 /* InitBasicFS for test_write_file_5: create ext2 on /dev/sda1 */
11144 char device[] = "/dev/sda";
11145 device[5] = devchar;
11147 suppress_error = 0;
11148 r = guestfs_blockdev_setrw (g, device);
11154 suppress_error = 0;
11155 r = guestfs_umount_all (g);
11161 suppress_error = 0;
11162 r = guestfs_lvm_remove_all (g);
11167 char device[] = "/dev/sda";
11168 device[5] = devchar;
11169 char lines_0[] = ",";
11175 suppress_error = 0;
11176 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11181 char fstype[] = "ext2";
11182 char device[] = "/dev/sda1";
11183 device[5] = devchar;
11185 suppress_error = 0;
11186 r = guestfs_mkfs (g, fstype, device);
11191 char device[] = "/dev/sda1";
11192 device[5] = devchar;
11193 char mountpoint[] = "/";
11195 suppress_error = 0;
11196 r = guestfs_mount (g, device, mountpoint);
11200 /* TestOutput for write_file (5) */
11201 char expected[] = "\n";
11203 char path[] = "/new";
11204 char content[] = "\n";
11206 suppress_error = 0;
11207 r = guestfs_write_file (g, path, content, 0);
11212 char path[] = "/new";
11214 suppress_error = 0;
11215 r = guestfs_cat (g, path);
11218 if (strcmp (r, expected) != 0) {
11219 fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
11227 static int test_mkfs_0_skip (void)
11231 str = getenv ("SKIP_TEST_MKFS_0");
11232 if (str && strcmp (str, "1") == 0) return 1;
11233 str = getenv ("SKIP_TEST_MKFS");
11234 if (str && strcmp (str, "1") == 0) return 1;
11238 static int test_mkfs_0 (void)
11240 if (test_mkfs_0_skip ()) {
11241 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkfs_0");
11245 /* InitNone|InitEmpty for test_mkfs_0 */
11247 char device[] = "/dev/sda";
11248 device[5] = devchar;
11250 suppress_error = 0;
11251 r = guestfs_blockdev_setrw (g, device);
11257 suppress_error = 0;
11258 r = guestfs_umount_all (g);
11264 suppress_error = 0;
11265 r = guestfs_lvm_remove_all (g);
11269 /* TestOutput for mkfs (0) */
11270 char expected[] = "new file contents";
11272 char device[] = "/dev/sda";
11273 device[5] = devchar;
11274 char lines_0[] = ",";
11280 suppress_error = 0;
11281 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11286 char fstype[] = "ext2";
11287 char device[] = "/dev/sda1";
11288 device[5] = devchar;
11290 suppress_error = 0;
11291 r = guestfs_mkfs (g, fstype, device);
11296 char device[] = "/dev/sda1";
11297 device[5] = devchar;
11298 char mountpoint[] = "/";
11300 suppress_error = 0;
11301 r = guestfs_mount (g, device, mountpoint);
11306 char path[] = "/new";
11307 char content[] = "new file contents";
11309 suppress_error = 0;
11310 r = guestfs_write_file (g, path, content, 0);
11315 char path[] = "/new";
11317 suppress_error = 0;
11318 r = guestfs_cat (g, path);
11321 if (strcmp (r, expected) != 0) {
11322 fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
11330 static int test_lvcreate_0_skip (void)
11334 str = getenv ("SKIP_TEST_LVCREATE_0");
11335 if (str && strcmp (str, "1") == 0) return 1;
11336 str = getenv ("SKIP_TEST_LVCREATE");
11337 if (str && strcmp (str, "1") == 0) return 1;
11341 static int test_lvcreate_0 (void)
11343 if (test_lvcreate_0_skip ()) {
11344 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvcreate_0");
11348 /* InitNone|InitEmpty for test_lvcreate_0 */
11350 char device[] = "/dev/sda";
11351 device[5] = devchar;
11353 suppress_error = 0;
11354 r = guestfs_blockdev_setrw (g, device);
11360 suppress_error = 0;
11361 r = guestfs_umount_all (g);
11367 suppress_error = 0;
11368 r = guestfs_lvm_remove_all (g);
11372 /* TestOutputList for lvcreate (0) */
11374 char device[] = "/dev/sda";
11375 device[5] = devchar;
11376 char lines_0[] = ",10";
11377 char lines_1[] = ",20";
11378 char lines_2[] = ",";
11386 suppress_error = 0;
11387 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11392 char device[] = "/dev/sda1";
11393 device[5] = devchar;
11395 suppress_error = 0;
11396 r = guestfs_pvcreate (g, device);
11401 char device[] = "/dev/sda2";
11402 device[5] = devchar;
11404 suppress_error = 0;
11405 r = guestfs_pvcreate (g, device);
11410 char device[] = "/dev/sda3";
11411 device[5] = devchar;
11413 suppress_error = 0;
11414 r = guestfs_pvcreate (g, device);
11419 char volgroup[] = "VG1";
11420 char physvols_0[] = "/dev/sda1";
11421 physvols_0[5] = devchar;
11422 char physvols_1[] = "/dev/sda2";
11423 physvols_1[5] = devchar;
11424 char *physvols[] = {
11430 suppress_error = 0;
11431 r = guestfs_vgcreate (g, volgroup, physvols);
11436 char volgroup[] = "VG2";
11437 char physvols_0[] = "/dev/sda3";
11438 physvols_0[5] = devchar;
11439 char *physvols[] = {
11444 suppress_error = 0;
11445 r = guestfs_vgcreate (g, volgroup, physvols);
11450 char logvol[] = "LV1";
11451 char volgroup[] = "VG1";
11453 suppress_error = 0;
11454 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11459 char logvol[] = "LV2";
11460 char volgroup[] = "VG1";
11462 suppress_error = 0;
11463 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11468 char logvol[] = "LV3";
11469 char volgroup[] = "VG2";
11471 suppress_error = 0;
11472 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11477 char logvol[] = "LV4";
11478 char volgroup[] = "VG2";
11480 suppress_error = 0;
11481 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11486 char logvol[] = "LV5";
11487 char volgroup[] = "VG2";
11489 suppress_error = 0;
11490 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11497 suppress_error = 0;
11498 r = guestfs_lvs (g);
11502 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11507 char expected[] = "/dev/VG1/LV1";
11508 if (strcmp (r[0], expected) != 0) {
11509 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11514 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11519 char expected[] = "/dev/VG1/LV2";
11520 if (strcmp (r[1], expected) != 0) {
11521 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11526 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11531 char expected[] = "/dev/VG2/LV3";
11532 if (strcmp (r[2], expected) != 0) {
11533 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
11538 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11543 char expected[] = "/dev/VG2/LV4";
11544 if (strcmp (r[3], expected) != 0) {
11545 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
11550 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11555 char expected[] = "/dev/VG2/LV5";
11556 if (strcmp (r[4], expected) != 0) {
11557 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
11561 if (r[5] != NULL) {
11562 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
11566 for (i = 0; r[i] != NULL; ++i)
11573 static int test_vgcreate_0_skip (void)
11577 str = getenv ("SKIP_TEST_VGCREATE_0");
11578 if (str && strcmp (str, "1") == 0) return 1;
11579 str = getenv ("SKIP_TEST_VGCREATE");
11580 if (str && strcmp (str, "1") == 0) return 1;
11584 static int test_vgcreate_0 (void)
11586 if (test_vgcreate_0_skip ()) {
11587 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgcreate_0");
11591 /* InitNone|InitEmpty for test_vgcreate_0 */
11593 char device[] = "/dev/sda";
11594 device[5] = devchar;
11596 suppress_error = 0;
11597 r = guestfs_blockdev_setrw (g, device);
11603 suppress_error = 0;
11604 r = guestfs_umount_all (g);
11610 suppress_error = 0;
11611 r = guestfs_lvm_remove_all (g);
11615 /* TestOutputList for vgcreate (0) */
11617 char device[] = "/dev/sda";
11618 device[5] = devchar;
11619 char lines_0[] = ",10";
11620 char lines_1[] = ",20";
11621 char lines_2[] = ",";
11629 suppress_error = 0;
11630 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11635 char device[] = "/dev/sda1";
11636 device[5] = devchar;
11638 suppress_error = 0;
11639 r = guestfs_pvcreate (g, device);
11644 char device[] = "/dev/sda2";
11645 device[5] = devchar;
11647 suppress_error = 0;
11648 r = guestfs_pvcreate (g, device);
11653 char device[] = "/dev/sda3";
11654 device[5] = devchar;
11656 suppress_error = 0;
11657 r = guestfs_pvcreate (g, device);
11662 char volgroup[] = "VG1";
11663 char physvols_0[] = "/dev/sda1";
11664 physvols_0[5] = devchar;
11665 char physvols_1[] = "/dev/sda2";
11666 physvols_1[5] = devchar;
11667 char *physvols[] = {
11673 suppress_error = 0;
11674 r = guestfs_vgcreate (g, volgroup, physvols);
11679 char volgroup[] = "VG2";
11680 char physvols_0[] = "/dev/sda3";
11681 physvols_0[5] = devchar;
11682 char *physvols[] = {
11687 suppress_error = 0;
11688 r = guestfs_vgcreate (g, volgroup, physvols);
11695 suppress_error = 0;
11696 r = guestfs_vgs (g);
11700 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
11705 char expected[] = "VG1";
11706 if (strcmp (r[0], expected) != 0) {
11707 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11712 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
11717 char expected[] = "VG2";
11718 if (strcmp (r[1], expected) != 0) {
11719 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11723 if (r[2] != NULL) {
11724 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
11728 for (i = 0; r[i] != NULL; ++i)
11735 static int test_pvcreate_0_skip (void)
11739 str = getenv ("SKIP_TEST_PVCREATE_0");
11740 if (str && strcmp (str, "1") == 0) return 1;
11741 str = getenv ("SKIP_TEST_PVCREATE");
11742 if (str && strcmp (str, "1") == 0) return 1;
11746 static int test_pvcreate_0 (void)
11748 if (test_pvcreate_0_skip ()) {
11749 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvcreate_0");
11753 /* InitNone|InitEmpty for test_pvcreate_0 */
11755 char device[] = "/dev/sda";
11756 device[5] = devchar;
11758 suppress_error = 0;
11759 r = guestfs_blockdev_setrw (g, device);
11765 suppress_error = 0;
11766 r = guestfs_umount_all (g);
11772 suppress_error = 0;
11773 r = guestfs_lvm_remove_all (g);
11777 /* TestOutputList for pvcreate (0) */
11779 char device[] = "/dev/sda";
11780 device[5] = devchar;
11781 char lines_0[] = ",10";
11782 char lines_1[] = ",20";
11783 char lines_2[] = ",";
11791 suppress_error = 0;
11792 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11797 char device[] = "/dev/sda1";
11798 device[5] = devchar;
11800 suppress_error = 0;
11801 r = guestfs_pvcreate (g, device);
11806 char device[] = "/dev/sda2";
11807 device[5] = devchar;
11809 suppress_error = 0;
11810 r = guestfs_pvcreate (g, device);
11815 char device[] = "/dev/sda3";
11816 device[5] = devchar;
11818 suppress_error = 0;
11819 r = guestfs_pvcreate (g, device);
11826 suppress_error = 0;
11827 r = guestfs_pvs (g);
11831 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
11836 char expected[] = "/dev/sda1";
11837 expected[5] = devchar;
11838 if (strcmp (r[0], expected) != 0) {
11839 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11844 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
11849 char expected[] = "/dev/sda2";
11850 expected[5] = devchar;
11851 if (strcmp (r[1], expected) != 0) {
11852 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11857 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
11862 char expected[] = "/dev/sda3";
11863 expected[5] = devchar;
11864 if (strcmp (r[2], expected) != 0) {
11865 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
11869 if (r[3] != NULL) {
11870 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
11874 for (i = 0; r[i] != NULL; ++i)
11881 static int test_is_dir_0_skip (void)
11885 str = getenv ("SKIP_TEST_IS_DIR_0");
11886 if (str && strcmp (str, "1") == 0) return 1;
11887 str = getenv ("SKIP_TEST_IS_DIR");
11888 if (str && strcmp (str, "1") == 0) return 1;
11892 static int test_is_dir_0 (void)
11894 if (test_is_dir_0_skip ()) {
11895 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_0");
11899 /* InitBasicFS for test_is_dir_0: create ext2 on /dev/sda1 */
11901 char device[] = "/dev/sda";
11902 device[5] = devchar;
11904 suppress_error = 0;
11905 r = guestfs_blockdev_setrw (g, device);
11911 suppress_error = 0;
11912 r = guestfs_umount_all (g);
11918 suppress_error = 0;
11919 r = guestfs_lvm_remove_all (g);
11924 char device[] = "/dev/sda";
11925 device[5] = devchar;
11926 char lines_0[] = ",";
11932 suppress_error = 0;
11933 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11938 char fstype[] = "ext2";
11939 char device[] = "/dev/sda1";
11940 device[5] = devchar;
11942 suppress_error = 0;
11943 r = guestfs_mkfs (g, fstype, device);
11948 char device[] = "/dev/sda1";
11949 device[5] = devchar;
11950 char mountpoint[] = "/";
11952 suppress_error = 0;
11953 r = guestfs_mount (g, device, mountpoint);
11957 /* TestOutputFalse for is_dir (0) */
11959 char path[] = "/new";
11961 suppress_error = 0;
11962 r = guestfs_touch (g, path);
11967 char path[] = "/new";
11969 suppress_error = 0;
11970 r = guestfs_is_dir (g, path);
11974 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
11981 static int test_is_dir_1_skip (void)
11985 str = getenv ("SKIP_TEST_IS_DIR_1");
11986 if (str && strcmp (str, "1") == 0) return 1;
11987 str = getenv ("SKIP_TEST_IS_DIR");
11988 if (str && strcmp (str, "1") == 0) return 1;
11992 static int test_is_dir_1 (void)
11994 if (test_is_dir_1_skip ()) {
11995 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_1");
11999 /* InitBasicFS for test_is_dir_1: create ext2 on /dev/sda1 */
12001 char device[] = "/dev/sda";
12002 device[5] = devchar;
12004 suppress_error = 0;
12005 r = guestfs_blockdev_setrw (g, device);
12011 suppress_error = 0;
12012 r = guestfs_umount_all (g);
12018 suppress_error = 0;
12019 r = guestfs_lvm_remove_all (g);
12024 char device[] = "/dev/sda";
12025 device[5] = devchar;
12026 char lines_0[] = ",";
12032 suppress_error = 0;
12033 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12038 char fstype[] = "ext2";
12039 char device[] = "/dev/sda1";
12040 device[5] = devchar;
12042 suppress_error = 0;
12043 r = guestfs_mkfs (g, fstype, device);
12048 char device[] = "/dev/sda1";
12049 device[5] = devchar;
12050 char mountpoint[] = "/";
12052 suppress_error = 0;
12053 r = guestfs_mount (g, device, mountpoint);
12057 /* TestOutputTrue for is_dir (1) */
12059 char path[] = "/new";
12061 suppress_error = 0;
12062 r = guestfs_mkdir (g, path);
12067 char path[] = "/new";
12069 suppress_error = 0;
12070 r = guestfs_is_dir (g, path);
12074 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
12081 static int test_is_file_0_skip (void)
12085 str = getenv ("SKIP_TEST_IS_FILE_0");
12086 if (str && strcmp (str, "1") == 0) return 1;
12087 str = getenv ("SKIP_TEST_IS_FILE");
12088 if (str && strcmp (str, "1") == 0) return 1;
12092 static int test_is_file_0 (void)
12094 if (test_is_file_0_skip ()) {
12095 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_0");
12099 /* InitBasicFS for test_is_file_0: create ext2 on /dev/sda1 */
12101 char device[] = "/dev/sda";
12102 device[5] = devchar;
12104 suppress_error = 0;
12105 r = guestfs_blockdev_setrw (g, device);
12111 suppress_error = 0;
12112 r = guestfs_umount_all (g);
12118 suppress_error = 0;
12119 r = guestfs_lvm_remove_all (g);
12124 char device[] = "/dev/sda";
12125 device[5] = devchar;
12126 char lines_0[] = ",";
12132 suppress_error = 0;
12133 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12138 char fstype[] = "ext2";
12139 char device[] = "/dev/sda1";
12140 device[5] = devchar;
12142 suppress_error = 0;
12143 r = guestfs_mkfs (g, fstype, device);
12148 char device[] = "/dev/sda1";
12149 device[5] = devchar;
12150 char mountpoint[] = "/";
12152 suppress_error = 0;
12153 r = guestfs_mount (g, device, mountpoint);
12157 /* TestOutputTrue for is_file (0) */
12159 char path[] = "/new";
12161 suppress_error = 0;
12162 r = guestfs_touch (g, path);
12167 char path[] = "/new";
12169 suppress_error = 0;
12170 r = guestfs_is_file (g, path);
12174 fprintf (stderr, "test_is_file_0: expected true, got false\n");
12181 static int test_is_file_1_skip (void)
12185 str = getenv ("SKIP_TEST_IS_FILE_1");
12186 if (str && strcmp (str, "1") == 0) return 1;
12187 str = getenv ("SKIP_TEST_IS_FILE");
12188 if (str && strcmp (str, "1") == 0) return 1;
12192 static int test_is_file_1 (void)
12194 if (test_is_file_1_skip ()) {
12195 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_1");
12199 /* InitBasicFS for test_is_file_1: create ext2 on /dev/sda1 */
12201 char device[] = "/dev/sda";
12202 device[5] = devchar;
12204 suppress_error = 0;
12205 r = guestfs_blockdev_setrw (g, device);
12211 suppress_error = 0;
12212 r = guestfs_umount_all (g);
12218 suppress_error = 0;
12219 r = guestfs_lvm_remove_all (g);
12224 char device[] = "/dev/sda";
12225 device[5] = devchar;
12226 char lines_0[] = ",";
12232 suppress_error = 0;
12233 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12238 char fstype[] = "ext2";
12239 char device[] = "/dev/sda1";
12240 device[5] = devchar;
12242 suppress_error = 0;
12243 r = guestfs_mkfs (g, fstype, device);
12248 char device[] = "/dev/sda1";
12249 device[5] = devchar;
12250 char mountpoint[] = "/";
12252 suppress_error = 0;
12253 r = guestfs_mount (g, device, mountpoint);
12257 /* TestOutputFalse for is_file (1) */
12259 char path[] = "/new";
12261 suppress_error = 0;
12262 r = guestfs_mkdir (g, path);
12267 char path[] = "/new";
12269 suppress_error = 0;
12270 r = guestfs_is_file (g, path);
12274 fprintf (stderr, "test_is_file_1: expected false, got true\n");
12281 static int test_exists_0_skip (void)
12285 str = getenv ("SKIP_TEST_EXISTS_0");
12286 if (str && strcmp (str, "1") == 0) return 1;
12287 str = getenv ("SKIP_TEST_EXISTS");
12288 if (str && strcmp (str, "1") == 0) return 1;
12292 static int test_exists_0 (void)
12294 if (test_exists_0_skip ()) {
12295 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_0");
12299 /* InitBasicFS for test_exists_0: create ext2 on /dev/sda1 */
12301 char device[] = "/dev/sda";
12302 device[5] = devchar;
12304 suppress_error = 0;
12305 r = guestfs_blockdev_setrw (g, device);
12311 suppress_error = 0;
12312 r = guestfs_umount_all (g);
12318 suppress_error = 0;
12319 r = guestfs_lvm_remove_all (g);
12324 char device[] = "/dev/sda";
12325 device[5] = devchar;
12326 char lines_0[] = ",";
12332 suppress_error = 0;
12333 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12338 char fstype[] = "ext2";
12339 char device[] = "/dev/sda1";
12340 device[5] = devchar;
12342 suppress_error = 0;
12343 r = guestfs_mkfs (g, fstype, device);
12348 char device[] = "/dev/sda1";
12349 device[5] = devchar;
12350 char mountpoint[] = "/";
12352 suppress_error = 0;
12353 r = guestfs_mount (g, device, mountpoint);
12357 /* TestOutputTrue for exists (0) */
12359 char path[] = "/new";
12361 suppress_error = 0;
12362 r = guestfs_touch (g, path);
12367 char path[] = "/new";
12369 suppress_error = 0;
12370 r = guestfs_exists (g, path);
12374 fprintf (stderr, "test_exists_0: expected true, got false\n");
12381 static int test_exists_1_skip (void)
12385 str = getenv ("SKIP_TEST_EXISTS_1");
12386 if (str && strcmp (str, "1") == 0) return 1;
12387 str = getenv ("SKIP_TEST_EXISTS");
12388 if (str && strcmp (str, "1") == 0) return 1;
12392 static int test_exists_1 (void)
12394 if (test_exists_1_skip ()) {
12395 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_1");
12399 /* InitBasicFS for test_exists_1: create ext2 on /dev/sda1 */
12401 char device[] = "/dev/sda";
12402 device[5] = devchar;
12404 suppress_error = 0;
12405 r = guestfs_blockdev_setrw (g, device);
12411 suppress_error = 0;
12412 r = guestfs_umount_all (g);
12418 suppress_error = 0;
12419 r = guestfs_lvm_remove_all (g);
12424 char device[] = "/dev/sda";
12425 device[5] = devchar;
12426 char lines_0[] = ",";
12432 suppress_error = 0;
12433 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12438 char fstype[] = "ext2";
12439 char device[] = "/dev/sda1";
12440 device[5] = devchar;
12442 suppress_error = 0;
12443 r = guestfs_mkfs (g, fstype, device);
12448 char device[] = "/dev/sda1";
12449 device[5] = devchar;
12450 char mountpoint[] = "/";
12452 suppress_error = 0;
12453 r = guestfs_mount (g, device, mountpoint);
12457 /* TestOutputTrue for exists (1) */
12459 char path[] = "/new";
12461 suppress_error = 0;
12462 r = guestfs_mkdir (g, path);
12467 char path[] = "/new";
12469 suppress_error = 0;
12470 r = guestfs_exists (g, path);
12474 fprintf (stderr, "test_exists_1: expected true, got false\n");
12481 static int test_mkdir_p_0_skip (void)
12485 str = getenv ("SKIP_TEST_MKDIR_P_0");
12486 if (str && strcmp (str, "1") == 0) return 1;
12487 str = getenv ("SKIP_TEST_MKDIR_P");
12488 if (str && strcmp (str, "1") == 0) return 1;
12492 static int test_mkdir_p_0 (void)
12494 if (test_mkdir_p_0_skip ()) {
12495 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_0");
12499 /* InitBasicFS for test_mkdir_p_0: create ext2 on /dev/sda1 */
12501 char device[] = "/dev/sda";
12502 device[5] = devchar;
12504 suppress_error = 0;
12505 r = guestfs_blockdev_setrw (g, device);
12511 suppress_error = 0;
12512 r = guestfs_umount_all (g);
12518 suppress_error = 0;
12519 r = guestfs_lvm_remove_all (g);
12524 char device[] = "/dev/sda";
12525 device[5] = devchar;
12526 char lines_0[] = ",";
12532 suppress_error = 0;
12533 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12538 char fstype[] = "ext2";
12539 char device[] = "/dev/sda1";
12540 device[5] = devchar;
12542 suppress_error = 0;
12543 r = guestfs_mkfs (g, fstype, device);
12548 char device[] = "/dev/sda1";
12549 device[5] = devchar;
12550 char mountpoint[] = "/";
12552 suppress_error = 0;
12553 r = guestfs_mount (g, device, mountpoint);
12557 /* TestOutputTrue for mkdir_p (0) */
12559 char path[] = "/new/foo/bar";
12561 suppress_error = 0;
12562 r = guestfs_mkdir_p (g, path);
12567 char path[] = "/new/foo/bar";
12569 suppress_error = 0;
12570 r = guestfs_is_dir (g, path);
12574 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
12581 static int test_mkdir_p_1_skip (void)
12585 str = getenv ("SKIP_TEST_MKDIR_P_1");
12586 if (str && strcmp (str, "1") == 0) return 1;
12587 str = getenv ("SKIP_TEST_MKDIR_P");
12588 if (str && strcmp (str, "1") == 0) return 1;
12592 static int test_mkdir_p_1 (void)
12594 if (test_mkdir_p_1_skip ()) {
12595 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_1");
12599 /* InitBasicFS for test_mkdir_p_1: create ext2 on /dev/sda1 */
12601 char device[] = "/dev/sda";
12602 device[5] = devchar;
12604 suppress_error = 0;
12605 r = guestfs_blockdev_setrw (g, device);
12611 suppress_error = 0;
12612 r = guestfs_umount_all (g);
12618 suppress_error = 0;
12619 r = guestfs_lvm_remove_all (g);
12624 char device[] = "/dev/sda";
12625 device[5] = devchar;
12626 char lines_0[] = ",";
12632 suppress_error = 0;
12633 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12638 char fstype[] = "ext2";
12639 char device[] = "/dev/sda1";
12640 device[5] = devchar;
12642 suppress_error = 0;
12643 r = guestfs_mkfs (g, fstype, device);
12648 char device[] = "/dev/sda1";
12649 device[5] = devchar;
12650 char mountpoint[] = "/";
12652 suppress_error = 0;
12653 r = guestfs_mount (g, device, mountpoint);
12657 /* TestOutputTrue for mkdir_p (1) */
12659 char path[] = "/new/foo/bar";
12661 suppress_error = 0;
12662 r = guestfs_mkdir_p (g, path);
12667 char path[] = "/new/foo";
12669 suppress_error = 0;
12670 r = guestfs_is_dir (g, path);
12674 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
12681 static int test_mkdir_p_2_skip (void)
12685 str = getenv ("SKIP_TEST_MKDIR_P_2");
12686 if (str && strcmp (str, "1") == 0) return 1;
12687 str = getenv ("SKIP_TEST_MKDIR_P");
12688 if (str && strcmp (str, "1") == 0) return 1;
12692 static int test_mkdir_p_2 (void)
12694 if (test_mkdir_p_2_skip ()) {
12695 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_2");
12699 /* InitBasicFS for test_mkdir_p_2: create ext2 on /dev/sda1 */
12701 char device[] = "/dev/sda";
12702 device[5] = devchar;
12704 suppress_error = 0;
12705 r = guestfs_blockdev_setrw (g, device);
12711 suppress_error = 0;
12712 r = guestfs_umount_all (g);
12718 suppress_error = 0;
12719 r = guestfs_lvm_remove_all (g);
12724 char device[] = "/dev/sda";
12725 device[5] = devchar;
12726 char lines_0[] = ",";
12732 suppress_error = 0;
12733 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12738 char fstype[] = "ext2";
12739 char device[] = "/dev/sda1";
12740 device[5] = devchar;
12742 suppress_error = 0;
12743 r = guestfs_mkfs (g, fstype, device);
12748 char device[] = "/dev/sda1";
12749 device[5] = devchar;
12750 char mountpoint[] = "/";
12752 suppress_error = 0;
12753 r = guestfs_mount (g, device, mountpoint);
12757 /* TestOutputTrue for mkdir_p (2) */
12759 char path[] = "/new/foo/bar";
12761 suppress_error = 0;
12762 r = guestfs_mkdir_p (g, path);
12767 char path[] = "/new";
12769 suppress_error = 0;
12770 r = guestfs_is_dir (g, path);
12774 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
12781 static int test_mkdir_0_skip (void)
12785 str = getenv ("SKIP_TEST_MKDIR_0");
12786 if (str && strcmp (str, "1") == 0) return 1;
12787 str = getenv ("SKIP_TEST_MKDIR");
12788 if (str && strcmp (str, "1") == 0) return 1;
12792 static int test_mkdir_0 (void)
12794 if (test_mkdir_0_skip ()) {
12795 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_0");
12799 /* InitBasicFS for test_mkdir_0: create ext2 on /dev/sda1 */
12801 char device[] = "/dev/sda";
12802 device[5] = devchar;
12804 suppress_error = 0;
12805 r = guestfs_blockdev_setrw (g, device);
12811 suppress_error = 0;
12812 r = guestfs_umount_all (g);
12818 suppress_error = 0;
12819 r = guestfs_lvm_remove_all (g);
12824 char device[] = "/dev/sda";
12825 device[5] = devchar;
12826 char lines_0[] = ",";
12832 suppress_error = 0;
12833 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12838 char fstype[] = "ext2";
12839 char device[] = "/dev/sda1";
12840 device[5] = devchar;
12842 suppress_error = 0;
12843 r = guestfs_mkfs (g, fstype, device);
12848 char device[] = "/dev/sda1";
12849 device[5] = devchar;
12850 char mountpoint[] = "/";
12852 suppress_error = 0;
12853 r = guestfs_mount (g, device, mountpoint);
12857 /* TestOutputTrue for mkdir (0) */
12859 char path[] = "/new";
12861 suppress_error = 0;
12862 r = guestfs_mkdir (g, path);
12867 char path[] = "/new";
12869 suppress_error = 0;
12870 r = guestfs_is_dir (g, path);
12874 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
12881 static int test_mkdir_1_skip (void)
12885 str = getenv ("SKIP_TEST_MKDIR_1");
12886 if (str && strcmp (str, "1") == 0) return 1;
12887 str = getenv ("SKIP_TEST_MKDIR");
12888 if (str && strcmp (str, "1") == 0) return 1;
12892 static int test_mkdir_1 (void)
12894 if (test_mkdir_1_skip ()) {
12895 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_1");
12899 /* InitBasicFS for test_mkdir_1: create ext2 on /dev/sda1 */
12901 char device[] = "/dev/sda";
12902 device[5] = devchar;
12904 suppress_error = 0;
12905 r = guestfs_blockdev_setrw (g, device);
12911 suppress_error = 0;
12912 r = guestfs_umount_all (g);
12918 suppress_error = 0;
12919 r = guestfs_lvm_remove_all (g);
12924 char device[] = "/dev/sda";
12925 device[5] = devchar;
12926 char lines_0[] = ",";
12932 suppress_error = 0;
12933 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12938 char fstype[] = "ext2";
12939 char device[] = "/dev/sda1";
12940 device[5] = devchar;
12942 suppress_error = 0;
12943 r = guestfs_mkfs (g, fstype, device);
12948 char device[] = "/dev/sda1";
12949 device[5] = devchar;
12950 char mountpoint[] = "/";
12952 suppress_error = 0;
12953 r = guestfs_mount (g, device, mountpoint);
12957 /* TestLastFail for mkdir (1) */
12959 char path[] = "/new/foo/bar";
12961 suppress_error = 1;
12962 r = guestfs_mkdir (g, path);
12969 static int test_rm_rf_0_skip (void)
12973 str = getenv ("SKIP_TEST_RM_RF_0");
12974 if (str && strcmp (str, "1") == 0) return 1;
12975 str = getenv ("SKIP_TEST_RM_RF");
12976 if (str && strcmp (str, "1") == 0) return 1;
12980 static int test_rm_rf_0 (void)
12982 if (test_rm_rf_0_skip ()) {
12983 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_rf_0");
12987 /* InitBasicFS for test_rm_rf_0: create ext2 on /dev/sda1 */
12989 char device[] = "/dev/sda";
12990 device[5] = devchar;
12992 suppress_error = 0;
12993 r = guestfs_blockdev_setrw (g, device);
12999 suppress_error = 0;
13000 r = guestfs_umount_all (g);
13006 suppress_error = 0;
13007 r = guestfs_lvm_remove_all (g);
13012 char device[] = "/dev/sda";
13013 device[5] = devchar;
13014 char lines_0[] = ",";
13020 suppress_error = 0;
13021 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13026 char fstype[] = "ext2";
13027 char device[] = "/dev/sda1";
13028 device[5] = devchar;
13030 suppress_error = 0;
13031 r = guestfs_mkfs (g, fstype, device);
13036 char device[] = "/dev/sda1";
13037 device[5] = devchar;
13038 char mountpoint[] = "/";
13040 suppress_error = 0;
13041 r = guestfs_mount (g, device, mountpoint);
13045 /* TestOutputFalse for rm_rf (0) */
13047 char path[] = "/new";
13049 suppress_error = 0;
13050 r = guestfs_mkdir (g, path);
13055 char path[] = "/new/foo";
13057 suppress_error = 0;
13058 r = guestfs_mkdir (g, path);
13063 char path[] = "/new/foo/bar";
13065 suppress_error = 0;
13066 r = guestfs_touch (g, path);
13071 char path[] = "/new";
13073 suppress_error = 0;
13074 r = guestfs_rm_rf (g, path);
13079 char path[] = "/new";
13081 suppress_error = 0;
13082 r = guestfs_exists (g, path);
13086 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
13093 static int test_rmdir_0_skip (void)
13097 str = getenv ("SKIP_TEST_RMDIR_0");
13098 if (str && strcmp (str, "1") == 0) return 1;
13099 str = getenv ("SKIP_TEST_RMDIR");
13100 if (str && strcmp (str, "1") == 0) return 1;
13104 static int test_rmdir_0 (void)
13106 if (test_rmdir_0_skip ()) {
13107 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_0");
13111 /* InitBasicFS for test_rmdir_0: create ext2 on /dev/sda1 */
13113 char device[] = "/dev/sda";
13114 device[5] = devchar;
13116 suppress_error = 0;
13117 r = guestfs_blockdev_setrw (g, device);
13123 suppress_error = 0;
13124 r = guestfs_umount_all (g);
13130 suppress_error = 0;
13131 r = guestfs_lvm_remove_all (g);
13136 char device[] = "/dev/sda";
13137 device[5] = devchar;
13138 char lines_0[] = ",";
13144 suppress_error = 0;
13145 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13150 char fstype[] = "ext2";
13151 char device[] = "/dev/sda1";
13152 device[5] = devchar;
13154 suppress_error = 0;
13155 r = guestfs_mkfs (g, fstype, device);
13160 char device[] = "/dev/sda1";
13161 device[5] = devchar;
13162 char mountpoint[] = "/";
13164 suppress_error = 0;
13165 r = guestfs_mount (g, device, mountpoint);
13169 /* TestRun for rmdir (0) */
13171 char path[] = "/new";
13173 suppress_error = 0;
13174 r = guestfs_mkdir (g, path);
13179 char path[] = "/new";
13181 suppress_error = 0;
13182 r = guestfs_rmdir (g, path);
13189 static int test_rmdir_1_skip (void)
13193 str = getenv ("SKIP_TEST_RMDIR_1");
13194 if (str && strcmp (str, "1") == 0) return 1;
13195 str = getenv ("SKIP_TEST_RMDIR");
13196 if (str && strcmp (str, "1") == 0) return 1;
13200 static int test_rmdir_1 (void)
13202 if (test_rmdir_1_skip ()) {
13203 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_1");
13207 /* InitBasicFS for test_rmdir_1: create ext2 on /dev/sda1 */
13209 char device[] = "/dev/sda";
13210 device[5] = devchar;
13212 suppress_error = 0;
13213 r = guestfs_blockdev_setrw (g, device);
13219 suppress_error = 0;
13220 r = guestfs_umount_all (g);
13226 suppress_error = 0;
13227 r = guestfs_lvm_remove_all (g);
13232 char device[] = "/dev/sda";
13233 device[5] = devchar;
13234 char lines_0[] = ",";
13240 suppress_error = 0;
13241 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13246 char fstype[] = "ext2";
13247 char device[] = "/dev/sda1";
13248 device[5] = devchar;
13250 suppress_error = 0;
13251 r = guestfs_mkfs (g, fstype, device);
13256 char device[] = "/dev/sda1";
13257 device[5] = devchar;
13258 char mountpoint[] = "/";
13260 suppress_error = 0;
13261 r = guestfs_mount (g, device, mountpoint);
13265 /* TestLastFail for rmdir (1) */
13267 char path[] = "/new";
13269 suppress_error = 1;
13270 r = guestfs_rmdir (g, path);
13277 static int test_rmdir_2_skip (void)
13281 str = getenv ("SKIP_TEST_RMDIR_2");
13282 if (str && strcmp (str, "1") == 0) return 1;
13283 str = getenv ("SKIP_TEST_RMDIR");
13284 if (str && strcmp (str, "1") == 0) return 1;
13288 static int test_rmdir_2 (void)
13290 if (test_rmdir_2_skip ()) {
13291 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_2");
13295 /* InitBasicFS for test_rmdir_2: create ext2 on /dev/sda1 */
13297 char device[] = "/dev/sda";
13298 device[5] = devchar;
13300 suppress_error = 0;
13301 r = guestfs_blockdev_setrw (g, device);
13307 suppress_error = 0;
13308 r = guestfs_umount_all (g);
13314 suppress_error = 0;
13315 r = guestfs_lvm_remove_all (g);
13320 char device[] = "/dev/sda";
13321 device[5] = devchar;
13322 char lines_0[] = ",";
13328 suppress_error = 0;
13329 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13334 char fstype[] = "ext2";
13335 char device[] = "/dev/sda1";
13336 device[5] = devchar;
13338 suppress_error = 0;
13339 r = guestfs_mkfs (g, fstype, device);
13344 char device[] = "/dev/sda1";
13345 device[5] = devchar;
13346 char mountpoint[] = "/";
13348 suppress_error = 0;
13349 r = guestfs_mount (g, device, mountpoint);
13353 /* TestLastFail for rmdir (2) */
13355 char path[] = "/new";
13357 suppress_error = 0;
13358 r = guestfs_touch (g, path);
13363 char path[] = "/new";
13365 suppress_error = 1;
13366 r = guestfs_rmdir (g, path);
13373 static int test_rm_0_skip (void)
13377 str = getenv ("SKIP_TEST_RM_0");
13378 if (str && strcmp (str, "1") == 0) return 1;
13379 str = getenv ("SKIP_TEST_RM");
13380 if (str && strcmp (str, "1") == 0) return 1;
13384 static int test_rm_0 (void)
13386 if (test_rm_0_skip ()) {
13387 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_0");
13391 /* InitBasicFS for test_rm_0: create ext2 on /dev/sda1 */
13393 char device[] = "/dev/sda";
13394 device[5] = devchar;
13396 suppress_error = 0;
13397 r = guestfs_blockdev_setrw (g, device);
13403 suppress_error = 0;
13404 r = guestfs_umount_all (g);
13410 suppress_error = 0;
13411 r = guestfs_lvm_remove_all (g);
13416 char device[] = "/dev/sda";
13417 device[5] = devchar;
13418 char lines_0[] = ",";
13424 suppress_error = 0;
13425 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13430 char fstype[] = "ext2";
13431 char device[] = "/dev/sda1";
13432 device[5] = devchar;
13434 suppress_error = 0;
13435 r = guestfs_mkfs (g, fstype, device);
13440 char device[] = "/dev/sda1";
13441 device[5] = devchar;
13442 char mountpoint[] = "/";
13444 suppress_error = 0;
13445 r = guestfs_mount (g, device, mountpoint);
13449 /* TestRun for rm (0) */
13451 char path[] = "/new";
13453 suppress_error = 0;
13454 r = guestfs_touch (g, path);
13459 char path[] = "/new";
13461 suppress_error = 0;
13462 r = guestfs_rm (g, path);
13469 static int test_rm_1_skip (void)
13473 str = getenv ("SKIP_TEST_RM_1");
13474 if (str && strcmp (str, "1") == 0) return 1;
13475 str = getenv ("SKIP_TEST_RM");
13476 if (str && strcmp (str, "1") == 0) return 1;
13480 static int test_rm_1 (void)
13482 if (test_rm_1_skip ()) {
13483 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_1");
13487 /* InitBasicFS for test_rm_1: create ext2 on /dev/sda1 */
13489 char device[] = "/dev/sda";
13490 device[5] = devchar;
13492 suppress_error = 0;
13493 r = guestfs_blockdev_setrw (g, device);
13499 suppress_error = 0;
13500 r = guestfs_umount_all (g);
13506 suppress_error = 0;
13507 r = guestfs_lvm_remove_all (g);
13512 char device[] = "/dev/sda";
13513 device[5] = devchar;
13514 char lines_0[] = ",";
13520 suppress_error = 0;
13521 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13526 char fstype[] = "ext2";
13527 char device[] = "/dev/sda1";
13528 device[5] = devchar;
13530 suppress_error = 0;
13531 r = guestfs_mkfs (g, fstype, device);
13536 char device[] = "/dev/sda1";
13537 device[5] = devchar;
13538 char mountpoint[] = "/";
13540 suppress_error = 0;
13541 r = guestfs_mount (g, device, mountpoint);
13545 /* TestLastFail for rm (1) */
13547 char path[] = "/new";
13549 suppress_error = 1;
13550 r = guestfs_rm (g, path);
13557 static int test_rm_2_skip (void)
13561 str = getenv ("SKIP_TEST_RM_2");
13562 if (str && strcmp (str, "1") == 0) return 1;
13563 str = getenv ("SKIP_TEST_RM");
13564 if (str && strcmp (str, "1") == 0) return 1;
13568 static int test_rm_2 (void)
13570 if (test_rm_2_skip ()) {
13571 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_2");
13575 /* InitBasicFS for test_rm_2: create ext2 on /dev/sda1 */
13577 char device[] = "/dev/sda";
13578 device[5] = devchar;
13580 suppress_error = 0;
13581 r = guestfs_blockdev_setrw (g, device);
13587 suppress_error = 0;
13588 r = guestfs_umount_all (g);
13594 suppress_error = 0;
13595 r = guestfs_lvm_remove_all (g);
13600 char device[] = "/dev/sda";
13601 device[5] = devchar;
13602 char lines_0[] = ",";
13608 suppress_error = 0;
13609 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13614 char fstype[] = "ext2";
13615 char device[] = "/dev/sda1";
13616 device[5] = devchar;
13618 suppress_error = 0;
13619 r = guestfs_mkfs (g, fstype, device);
13624 char device[] = "/dev/sda1";
13625 device[5] = devchar;
13626 char mountpoint[] = "/";
13628 suppress_error = 0;
13629 r = guestfs_mount (g, device, mountpoint);
13633 /* TestLastFail for rm (2) */
13635 char path[] = "/new";
13637 suppress_error = 0;
13638 r = guestfs_mkdir (g, path);
13643 char path[] = "/new";
13645 suppress_error = 1;
13646 r = guestfs_rm (g, path);
13653 static int test_read_lines_0_skip (void)
13657 str = getenv ("SKIP_TEST_READ_LINES_0");
13658 if (str && strcmp (str, "1") == 0) return 1;
13659 str = getenv ("SKIP_TEST_READ_LINES");
13660 if (str && strcmp (str, "1") == 0) return 1;
13664 static int test_read_lines_0 (void)
13666 if (test_read_lines_0_skip ()) {
13667 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_0");
13671 /* InitBasicFS for test_read_lines_0: create ext2 on /dev/sda1 */
13673 char device[] = "/dev/sda";
13674 device[5] = devchar;
13676 suppress_error = 0;
13677 r = guestfs_blockdev_setrw (g, device);
13683 suppress_error = 0;
13684 r = guestfs_umount_all (g);
13690 suppress_error = 0;
13691 r = guestfs_lvm_remove_all (g);
13696 char device[] = "/dev/sda";
13697 device[5] = devchar;
13698 char lines_0[] = ",";
13704 suppress_error = 0;
13705 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13710 char fstype[] = "ext2";
13711 char device[] = "/dev/sda1";
13712 device[5] = devchar;
13714 suppress_error = 0;
13715 r = guestfs_mkfs (g, fstype, device);
13720 char device[] = "/dev/sda1";
13721 device[5] = devchar;
13722 char mountpoint[] = "/";
13724 suppress_error = 0;
13725 r = guestfs_mount (g, device, mountpoint);
13729 /* TestOutputList for read_lines (0) */
13731 char path[] = "/new";
13732 char content[] = "line1\r\nline2\nline3";
13734 suppress_error = 0;
13735 r = guestfs_write_file (g, path, content, 0);
13740 char path[] = "/new";
13743 suppress_error = 0;
13744 r = guestfs_read_lines (g, path);
13748 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
13753 char expected[] = "line1";
13754 if (strcmp (r[0], expected) != 0) {
13755 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
13760 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
13765 char expected[] = "line2";
13766 if (strcmp (r[1], expected) != 0) {
13767 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
13772 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
13777 char expected[] = "line3";
13778 if (strcmp (r[2], expected) != 0) {
13779 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
13783 if (r[3] != NULL) {
13784 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
13788 for (i = 0; r[i] != NULL; ++i)
13795 static int test_read_lines_1_skip (void)
13799 str = getenv ("SKIP_TEST_READ_LINES_1");
13800 if (str && strcmp (str, "1") == 0) return 1;
13801 str = getenv ("SKIP_TEST_READ_LINES");
13802 if (str && strcmp (str, "1") == 0) return 1;
13806 static int test_read_lines_1 (void)
13808 if (test_read_lines_1_skip ()) {
13809 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_1");
13813 /* InitBasicFS for test_read_lines_1: create ext2 on /dev/sda1 */
13815 char device[] = "/dev/sda";
13816 device[5] = devchar;
13818 suppress_error = 0;
13819 r = guestfs_blockdev_setrw (g, device);
13825 suppress_error = 0;
13826 r = guestfs_umount_all (g);
13832 suppress_error = 0;
13833 r = guestfs_lvm_remove_all (g);
13838 char device[] = "/dev/sda";
13839 device[5] = devchar;
13840 char lines_0[] = ",";
13846 suppress_error = 0;
13847 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13852 char fstype[] = "ext2";
13853 char device[] = "/dev/sda1";
13854 device[5] = devchar;
13856 suppress_error = 0;
13857 r = guestfs_mkfs (g, fstype, device);
13862 char device[] = "/dev/sda1";
13863 device[5] = devchar;
13864 char mountpoint[] = "/";
13866 suppress_error = 0;
13867 r = guestfs_mount (g, device, mountpoint);
13871 /* TestOutputList for read_lines (1) */
13873 char path[] = "/new";
13874 char content[] = "";
13876 suppress_error = 0;
13877 r = guestfs_write_file (g, path, content, 0);
13882 char path[] = "/new";
13885 suppress_error = 0;
13886 r = guestfs_read_lines (g, path);
13889 if (r[0] != NULL) {
13890 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
13894 for (i = 0; r[i] != NULL; ++i)
13901 static int test_lvs_0_skip (void)
13905 str = getenv ("SKIP_TEST_LVS_0");
13906 if (str && strcmp (str, "1") == 0) return 1;
13907 str = getenv ("SKIP_TEST_LVS");
13908 if (str && strcmp (str, "1") == 0) return 1;
13912 static int test_lvs_0 (void)
13914 if (test_lvs_0_skip ()) {
13915 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_0");
13919 /* InitBasicFSonLVM for test_lvs_0: create ext2 on /dev/VG/LV */
13921 char device[] = "/dev/sda";
13922 device[5] = devchar;
13924 suppress_error = 0;
13925 r = guestfs_blockdev_setrw (g, device);
13931 suppress_error = 0;
13932 r = guestfs_umount_all (g);
13938 suppress_error = 0;
13939 r = guestfs_lvm_remove_all (g);
13944 char device[] = "/dev/sda";
13945 device[5] = devchar;
13946 char lines_0[] = ",";
13952 suppress_error = 0;
13953 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13958 char device[] = "/dev/sda1";
13959 device[5] = devchar;
13961 suppress_error = 0;
13962 r = guestfs_pvcreate (g, device);
13967 char volgroup[] = "VG";
13968 char physvols_0[] = "/dev/sda1";
13969 physvols_0[5] = devchar;
13970 char *physvols[] = {
13975 suppress_error = 0;
13976 r = guestfs_vgcreate (g, volgroup, physvols);
13981 char logvol[] = "LV";
13982 char volgroup[] = "VG";
13984 suppress_error = 0;
13985 r = guestfs_lvcreate (g, logvol, volgroup, 8);
13990 char fstype[] = "ext2";
13991 char device[] = "/dev/VG/LV";
13993 suppress_error = 0;
13994 r = guestfs_mkfs (g, fstype, device);
13999 char device[] = "/dev/VG/LV";
14000 char mountpoint[] = "/";
14002 suppress_error = 0;
14003 r = guestfs_mount (g, device, mountpoint);
14007 /* TestOutputList for lvs (0) */
14011 suppress_error = 0;
14012 r = guestfs_lvs (g);
14016 fprintf (stderr, "test_lvs_0: short list returned from command\n");
14021 char expected[] = "/dev/VG/LV";
14022 if (strcmp (r[0], expected) != 0) {
14023 fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14027 if (r[1] != NULL) {
14028 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
14032 for (i = 0; r[i] != NULL; ++i)
14039 static int test_lvs_1_skip (void)
14043 str = getenv ("SKIP_TEST_LVS_1");
14044 if (str && strcmp (str, "1") == 0) return 1;
14045 str = getenv ("SKIP_TEST_LVS");
14046 if (str && strcmp (str, "1") == 0) return 1;
14050 static int test_lvs_1 (void)
14052 if (test_lvs_1_skip ()) {
14053 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_1");
14057 /* InitNone|InitEmpty for test_lvs_1 */
14059 char device[] = "/dev/sda";
14060 device[5] = devchar;
14062 suppress_error = 0;
14063 r = guestfs_blockdev_setrw (g, device);
14069 suppress_error = 0;
14070 r = guestfs_umount_all (g);
14076 suppress_error = 0;
14077 r = guestfs_lvm_remove_all (g);
14081 /* TestOutputList for lvs (1) */
14083 char device[] = "/dev/sda";
14084 device[5] = devchar;
14085 char lines_0[] = ",10";
14086 char lines_1[] = ",20";
14087 char lines_2[] = ",";
14095 suppress_error = 0;
14096 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14101 char device[] = "/dev/sda1";
14102 device[5] = devchar;
14104 suppress_error = 0;
14105 r = guestfs_pvcreate (g, device);
14110 char device[] = "/dev/sda2";
14111 device[5] = devchar;
14113 suppress_error = 0;
14114 r = guestfs_pvcreate (g, device);
14119 char device[] = "/dev/sda3";
14120 device[5] = devchar;
14122 suppress_error = 0;
14123 r = guestfs_pvcreate (g, device);
14128 char volgroup[] = "VG1";
14129 char physvols_0[] = "/dev/sda1";
14130 physvols_0[5] = devchar;
14131 char physvols_1[] = "/dev/sda2";
14132 physvols_1[5] = devchar;
14133 char *physvols[] = {
14139 suppress_error = 0;
14140 r = guestfs_vgcreate (g, volgroup, physvols);
14145 char volgroup[] = "VG2";
14146 char physvols_0[] = "/dev/sda3";
14147 physvols_0[5] = devchar;
14148 char *physvols[] = {
14153 suppress_error = 0;
14154 r = guestfs_vgcreate (g, volgroup, physvols);
14159 char logvol[] = "LV1";
14160 char volgroup[] = "VG1";
14162 suppress_error = 0;
14163 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14168 char logvol[] = "LV2";
14169 char volgroup[] = "VG1";
14171 suppress_error = 0;
14172 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14177 char logvol[] = "LV3";
14178 char volgroup[] = "VG2";
14180 suppress_error = 0;
14181 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14188 suppress_error = 0;
14189 r = guestfs_lvs (g);
14193 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14198 char expected[] = "/dev/VG1/LV1";
14199 if (strcmp (r[0], expected) != 0) {
14200 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14205 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14210 char expected[] = "/dev/VG1/LV2";
14211 if (strcmp (r[1], expected) != 0) {
14212 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14217 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14222 char expected[] = "/dev/VG2/LV3";
14223 if (strcmp (r[2], expected) != 0) {
14224 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14228 if (r[3] != NULL) {
14229 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
14233 for (i = 0; r[i] != NULL; ++i)
14240 static int test_vgs_0_skip (void)
14244 str = getenv ("SKIP_TEST_VGS_0");
14245 if (str && strcmp (str, "1") == 0) return 1;
14246 str = getenv ("SKIP_TEST_VGS");
14247 if (str && strcmp (str, "1") == 0) return 1;
14251 static int test_vgs_0 (void)
14253 if (test_vgs_0_skip ()) {
14254 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_0");
14258 /* InitBasicFSonLVM for test_vgs_0: create ext2 on /dev/VG/LV */
14260 char device[] = "/dev/sda";
14261 device[5] = devchar;
14263 suppress_error = 0;
14264 r = guestfs_blockdev_setrw (g, device);
14270 suppress_error = 0;
14271 r = guestfs_umount_all (g);
14277 suppress_error = 0;
14278 r = guestfs_lvm_remove_all (g);
14283 char device[] = "/dev/sda";
14284 device[5] = devchar;
14285 char lines_0[] = ",";
14291 suppress_error = 0;
14292 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14297 char device[] = "/dev/sda1";
14298 device[5] = devchar;
14300 suppress_error = 0;
14301 r = guestfs_pvcreate (g, device);
14306 char volgroup[] = "VG";
14307 char physvols_0[] = "/dev/sda1";
14308 physvols_0[5] = devchar;
14309 char *physvols[] = {
14314 suppress_error = 0;
14315 r = guestfs_vgcreate (g, volgroup, physvols);
14320 char logvol[] = "LV";
14321 char volgroup[] = "VG";
14323 suppress_error = 0;
14324 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14329 char fstype[] = "ext2";
14330 char device[] = "/dev/VG/LV";
14332 suppress_error = 0;
14333 r = guestfs_mkfs (g, fstype, device);
14338 char device[] = "/dev/VG/LV";
14339 char mountpoint[] = "/";
14341 suppress_error = 0;
14342 r = guestfs_mount (g, device, mountpoint);
14346 /* TestOutputList for vgs (0) */
14350 suppress_error = 0;
14351 r = guestfs_vgs (g);
14355 fprintf (stderr, "test_vgs_0: short list returned from command\n");
14360 char expected[] = "VG";
14361 if (strcmp (r[0], expected) != 0) {
14362 fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14366 if (r[1] != NULL) {
14367 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
14371 for (i = 0; r[i] != NULL; ++i)
14378 static int test_vgs_1_skip (void)
14382 str = getenv ("SKIP_TEST_VGS_1");
14383 if (str && strcmp (str, "1") == 0) return 1;
14384 str = getenv ("SKIP_TEST_VGS");
14385 if (str && strcmp (str, "1") == 0) return 1;
14389 static int test_vgs_1 (void)
14391 if (test_vgs_1_skip ()) {
14392 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_1");
14396 /* InitNone|InitEmpty for test_vgs_1 */
14398 char device[] = "/dev/sda";
14399 device[5] = devchar;
14401 suppress_error = 0;
14402 r = guestfs_blockdev_setrw (g, device);
14408 suppress_error = 0;
14409 r = guestfs_umount_all (g);
14415 suppress_error = 0;
14416 r = guestfs_lvm_remove_all (g);
14420 /* TestOutputList for vgs (1) */
14422 char device[] = "/dev/sda";
14423 device[5] = devchar;
14424 char lines_0[] = ",10";
14425 char lines_1[] = ",20";
14426 char lines_2[] = ",";
14434 suppress_error = 0;
14435 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14440 char device[] = "/dev/sda1";
14441 device[5] = devchar;
14443 suppress_error = 0;
14444 r = guestfs_pvcreate (g, device);
14449 char device[] = "/dev/sda2";
14450 device[5] = devchar;
14452 suppress_error = 0;
14453 r = guestfs_pvcreate (g, device);
14458 char device[] = "/dev/sda3";
14459 device[5] = devchar;
14461 suppress_error = 0;
14462 r = guestfs_pvcreate (g, device);
14467 char volgroup[] = "VG1";
14468 char physvols_0[] = "/dev/sda1";
14469 physvols_0[5] = devchar;
14470 char physvols_1[] = "/dev/sda2";
14471 physvols_1[5] = devchar;
14472 char *physvols[] = {
14478 suppress_error = 0;
14479 r = guestfs_vgcreate (g, volgroup, physvols);
14484 char volgroup[] = "VG2";
14485 char physvols_0[] = "/dev/sda3";
14486 physvols_0[5] = devchar;
14487 char *physvols[] = {
14492 suppress_error = 0;
14493 r = guestfs_vgcreate (g, volgroup, physvols);
14500 suppress_error = 0;
14501 r = guestfs_vgs (g);
14505 fprintf (stderr, "test_vgs_1: short list returned from command\n");
14510 char expected[] = "VG1";
14511 if (strcmp (r[0], expected) != 0) {
14512 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14517 fprintf (stderr, "test_vgs_1: short list returned from command\n");
14522 char expected[] = "VG2";
14523 if (strcmp (r[1], expected) != 0) {
14524 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14528 if (r[2] != NULL) {
14529 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
14533 for (i = 0; r[i] != NULL; ++i)
14540 static int test_pvs_0_skip (void)
14544 str = getenv ("SKIP_TEST_PVS_0");
14545 if (str && strcmp (str, "1") == 0) return 1;
14546 str = getenv ("SKIP_TEST_PVS");
14547 if (str && strcmp (str, "1") == 0) return 1;
14551 static int test_pvs_0 (void)
14553 if (test_pvs_0_skip ()) {
14554 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_0");
14558 /* InitBasicFSonLVM for test_pvs_0: create ext2 on /dev/VG/LV */
14560 char device[] = "/dev/sda";
14561 device[5] = devchar;
14563 suppress_error = 0;
14564 r = guestfs_blockdev_setrw (g, device);
14570 suppress_error = 0;
14571 r = guestfs_umount_all (g);
14577 suppress_error = 0;
14578 r = guestfs_lvm_remove_all (g);
14583 char device[] = "/dev/sda";
14584 device[5] = devchar;
14585 char lines_0[] = ",";
14591 suppress_error = 0;
14592 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14597 char device[] = "/dev/sda1";
14598 device[5] = devchar;
14600 suppress_error = 0;
14601 r = guestfs_pvcreate (g, device);
14606 char volgroup[] = "VG";
14607 char physvols_0[] = "/dev/sda1";
14608 physvols_0[5] = devchar;
14609 char *physvols[] = {
14614 suppress_error = 0;
14615 r = guestfs_vgcreate (g, volgroup, physvols);
14620 char logvol[] = "LV";
14621 char volgroup[] = "VG";
14623 suppress_error = 0;
14624 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14629 char fstype[] = "ext2";
14630 char device[] = "/dev/VG/LV";
14632 suppress_error = 0;
14633 r = guestfs_mkfs (g, fstype, device);
14638 char device[] = "/dev/VG/LV";
14639 char mountpoint[] = "/";
14641 suppress_error = 0;
14642 r = guestfs_mount (g, device, mountpoint);
14646 /* TestOutputList for pvs (0) */
14650 suppress_error = 0;
14651 r = guestfs_pvs (g);
14655 fprintf (stderr, "test_pvs_0: short list returned from command\n");
14660 char expected[] = "/dev/sda1";
14661 expected[5] = devchar;
14662 if (strcmp (r[0], expected) != 0) {
14663 fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14667 if (r[1] != NULL) {
14668 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
14672 for (i = 0; r[i] != NULL; ++i)
14679 static int test_pvs_1_skip (void)
14683 str = getenv ("SKIP_TEST_PVS_1");
14684 if (str && strcmp (str, "1") == 0) return 1;
14685 str = getenv ("SKIP_TEST_PVS");
14686 if (str && strcmp (str, "1") == 0) return 1;
14690 static int test_pvs_1 (void)
14692 if (test_pvs_1_skip ()) {
14693 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_1");
14697 /* InitNone|InitEmpty for test_pvs_1 */
14699 char device[] = "/dev/sda";
14700 device[5] = devchar;
14702 suppress_error = 0;
14703 r = guestfs_blockdev_setrw (g, device);
14709 suppress_error = 0;
14710 r = guestfs_umount_all (g);
14716 suppress_error = 0;
14717 r = guestfs_lvm_remove_all (g);
14721 /* TestOutputList for pvs (1) */
14723 char device[] = "/dev/sda";
14724 device[5] = devchar;
14725 char lines_0[] = ",10";
14726 char lines_1[] = ",20";
14727 char lines_2[] = ",";
14735 suppress_error = 0;
14736 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14741 char device[] = "/dev/sda1";
14742 device[5] = devchar;
14744 suppress_error = 0;
14745 r = guestfs_pvcreate (g, device);
14750 char device[] = "/dev/sda2";
14751 device[5] = devchar;
14753 suppress_error = 0;
14754 r = guestfs_pvcreate (g, device);
14759 char device[] = "/dev/sda3";
14760 device[5] = devchar;
14762 suppress_error = 0;
14763 r = guestfs_pvcreate (g, device);
14770 suppress_error = 0;
14771 r = guestfs_pvs (g);
14775 fprintf (stderr, "test_pvs_1: short list returned from command\n");
14780 char expected[] = "/dev/sda1";
14781 expected[5] = devchar;
14782 if (strcmp (r[0], expected) != 0) {
14783 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14788 fprintf (stderr, "test_pvs_1: short list returned from command\n");
14793 char expected[] = "/dev/sda2";
14794 expected[5] = devchar;
14795 if (strcmp (r[1], expected) != 0) {
14796 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14801 fprintf (stderr, "test_pvs_1: short list returned from command\n");
14806 char expected[] = "/dev/sda3";
14807 expected[5] = devchar;
14808 if (strcmp (r[2], expected) != 0) {
14809 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14813 if (r[3] != NULL) {
14814 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
14818 for (i = 0; r[i] != NULL; ++i)
14825 static int test_list_partitions_0_skip (void)
14829 str = getenv ("SKIP_TEST_LIST_PARTITIONS_0");
14830 if (str && strcmp (str, "1") == 0) return 1;
14831 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
14832 if (str && strcmp (str, "1") == 0) return 1;
14836 static int test_list_partitions_0 (void)
14838 if (test_list_partitions_0_skip ()) {
14839 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_0");
14843 /* InitBasicFS for test_list_partitions_0: create ext2 on /dev/sda1 */
14845 char device[] = "/dev/sda";
14846 device[5] = devchar;
14848 suppress_error = 0;
14849 r = guestfs_blockdev_setrw (g, device);
14855 suppress_error = 0;
14856 r = guestfs_umount_all (g);
14862 suppress_error = 0;
14863 r = guestfs_lvm_remove_all (g);
14868 char device[] = "/dev/sda";
14869 device[5] = devchar;
14870 char lines_0[] = ",";
14876 suppress_error = 0;
14877 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14882 char fstype[] = "ext2";
14883 char device[] = "/dev/sda1";
14884 device[5] = devchar;
14886 suppress_error = 0;
14887 r = guestfs_mkfs (g, fstype, device);
14892 char device[] = "/dev/sda1";
14893 device[5] = devchar;
14894 char mountpoint[] = "/";
14896 suppress_error = 0;
14897 r = guestfs_mount (g, device, mountpoint);
14901 /* TestOutputList for list_partitions (0) */
14905 suppress_error = 0;
14906 r = guestfs_list_partitions (g);
14910 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
14915 char expected[] = "/dev/sda1";
14916 expected[5] = devchar;
14917 if (strcmp (r[0], expected) != 0) {
14918 fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14922 if (r[1] != NULL) {
14923 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
14927 for (i = 0; r[i] != NULL; ++i)
14934 static int test_list_partitions_1_skip (void)
14938 str = getenv ("SKIP_TEST_LIST_PARTITIONS_1");
14939 if (str && strcmp (str, "1") == 0) return 1;
14940 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
14941 if (str && strcmp (str, "1") == 0) return 1;
14945 static int test_list_partitions_1 (void)
14947 if (test_list_partitions_1_skip ()) {
14948 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_1");
14952 /* InitNone|InitEmpty for test_list_partitions_1 */
14954 char device[] = "/dev/sda";
14955 device[5] = devchar;
14957 suppress_error = 0;
14958 r = guestfs_blockdev_setrw (g, device);
14964 suppress_error = 0;
14965 r = guestfs_umount_all (g);
14971 suppress_error = 0;
14972 r = guestfs_lvm_remove_all (g);
14976 /* TestOutputList for list_partitions (1) */
14978 char device[] = "/dev/sda";
14979 device[5] = devchar;
14980 char lines_0[] = ",10";
14981 char lines_1[] = ",20";
14982 char lines_2[] = ",";
14990 suppress_error = 0;
14991 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14998 suppress_error = 0;
14999 r = guestfs_list_partitions (g);
15003 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15008 char expected[] = "/dev/sda1";
15009 expected[5] = devchar;
15010 if (strcmp (r[0], expected) != 0) {
15011 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15016 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15021 char expected[] = "/dev/sda2";
15022 expected[5] = devchar;
15023 if (strcmp (r[1], expected) != 0) {
15024 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15029 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15034 char expected[] = "/dev/sda3";
15035 expected[5] = devchar;
15036 if (strcmp (r[2], expected) != 0) {
15037 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15041 if (r[3] != NULL) {
15042 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
15046 for (i = 0; r[i] != NULL; ++i)
15053 static int test_list_devices_0_skip (void)
15057 str = getenv ("SKIP_TEST_LIST_DEVICES_0");
15058 if (str && strcmp (str, "1") == 0) return 1;
15059 str = getenv ("SKIP_TEST_LIST_DEVICES");
15060 if (str && strcmp (str, "1") == 0) return 1;
15064 static int test_list_devices_0 (void)
15066 if (test_list_devices_0_skip ()) {
15067 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_devices_0");
15071 /* InitNone|InitEmpty for test_list_devices_0 */
15073 char device[] = "/dev/sda";
15074 device[5] = devchar;
15076 suppress_error = 0;
15077 r = guestfs_blockdev_setrw (g, device);
15083 suppress_error = 0;
15084 r = guestfs_umount_all (g);
15090 suppress_error = 0;
15091 r = guestfs_lvm_remove_all (g);
15095 /* TestOutputList for list_devices (0) */
15099 suppress_error = 0;
15100 r = guestfs_list_devices (g);
15104 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15109 char expected[] = "/dev/sda";
15110 expected[5] = devchar;
15111 if (strcmp (r[0], expected) != 0) {
15112 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15117 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15122 char expected[] = "/dev/sdb";
15123 expected[5] = devchar;
15124 if (strcmp (r[1], expected) != 0) {
15125 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15130 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15135 char expected[] = "/dev/sdc";
15136 expected[5] = devchar;
15137 if (strcmp (r[2], expected) != 0) {
15138 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15142 if (r[3] != NULL) {
15143 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
15147 for (i = 0; r[i] != NULL; ++i)
15154 static int test_ls_0_skip (void)
15158 str = getenv ("SKIP_TEST_LS_0");
15159 if (str && strcmp (str, "1") == 0) return 1;
15160 str = getenv ("SKIP_TEST_LS");
15161 if (str && strcmp (str, "1") == 0) return 1;
15165 static int test_ls_0 (void)
15167 if (test_ls_0_skip ()) {
15168 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ls_0");
15172 /* InitBasicFS for test_ls_0: create ext2 on /dev/sda1 */
15174 char device[] = "/dev/sda";
15175 device[5] = devchar;
15177 suppress_error = 0;
15178 r = guestfs_blockdev_setrw (g, device);
15184 suppress_error = 0;
15185 r = guestfs_umount_all (g);
15191 suppress_error = 0;
15192 r = guestfs_lvm_remove_all (g);
15197 char device[] = "/dev/sda";
15198 device[5] = devchar;
15199 char lines_0[] = ",";
15205 suppress_error = 0;
15206 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15211 char fstype[] = "ext2";
15212 char device[] = "/dev/sda1";
15213 device[5] = devchar;
15215 suppress_error = 0;
15216 r = guestfs_mkfs (g, fstype, device);
15221 char device[] = "/dev/sda1";
15222 device[5] = devchar;
15223 char mountpoint[] = "/";
15225 suppress_error = 0;
15226 r = guestfs_mount (g, device, mountpoint);
15230 /* TestOutputList for ls (0) */
15232 char path[] = "/new";
15234 suppress_error = 0;
15235 r = guestfs_touch (g, path);
15240 char path[] = "/newer";
15242 suppress_error = 0;
15243 r = guestfs_touch (g, path);
15248 char path[] = "/newest";
15250 suppress_error = 0;
15251 r = guestfs_touch (g, path);
15256 char directory[] = "/";
15259 suppress_error = 0;
15260 r = guestfs_ls (g, directory);
15264 fprintf (stderr, "test_ls_0: short list returned from command\n");
15269 char expected[] = "lost+found";
15270 if (strcmp (r[0], expected) != 0) {
15271 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15276 fprintf (stderr, "test_ls_0: short list returned from command\n");
15281 char expected[] = "new";
15282 if (strcmp (r[1], expected) != 0) {
15283 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15288 fprintf (stderr, "test_ls_0: short list returned from command\n");
15293 char expected[] = "newer";
15294 if (strcmp (r[2], expected) != 0) {
15295 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15300 fprintf (stderr, "test_ls_0: short list returned from command\n");
15305 char expected[] = "newest";
15306 if (strcmp (r[3], expected) != 0) {
15307 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
15311 if (r[4] != NULL) {
15312 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
15316 for (i = 0; r[i] != NULL; ++i)
15323 static int test_cat_0_skip (void)
15327 str = getenv ("SKIP_TEST_CAT_0");
15328 if (str && strcmp (str, "1") == 0) return 1;
15329 str = getenv ("SKIP_TEST_CAT");
15330 if (str && strcmp (str, "1") == 0) return 1;
15334 static int test_cat_0 (void)
15336 if (test_cat_0_skip ()) {
15337 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cat_0");
15341 /* InitBasicFS for test_cat_0: create ext2 on /dev/sda1 */
15343 char device[] = "/dev/sda";
15344 device[5] = devchar;
15346 suppress_error = 0;
15347 r = guestfs_blockdev_setrw (g, device);
15353 suppress_error = 0;
15354 r = guestfs_umount_all (g);
15360 suppress_error = 0;
15361 r = guestfs_lvm_remove_all (g);
15366 char device[] = "/dev/sda";
15367 device[5] = devchar;
15368 char lines_0[] = ",";
15374 suppress_error = 0;
15375 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15380 char fstype[] = "ext2";
15381 char device[] = "/dev/sda1";
15382 device[5] = devchar;
15384 suppress_error = 0;
15385 r = guestfs_mkfs (g, fstype, device);
15390 char device[] = "/dev/sda1";
15391 device[5] = devchar;
15392 char mountpoint[] = "/";
15394 suppress_error = 0;
15395 r = guestfs_mount (g, device, mountpoint);
15399 /* TestOutput for cat (0) */
15400 char expected[] = "new file contents";
15402 char path[] = "/new";
15403 char content[] = "new file contents";
15405 suppress_error = 0;
15406 r = guestfs_write_file (g, path, content, 0);
15411 char path[] = "/new";
15413 suppress_error = 0;
15414 r = guestfs_cat (g, path);
15417 if (strcmp (r, expected) != 0) {
15418 fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
15426 static int test_touch_0_skip (void)
15430 str = getenv ("SKIP_TEST_TOUCH_0");
15431 if (str && strcmp (str, "1") == 0) return 1;
15432 str = getenv ("SKIP_TEST_TOUCH");
15433 if (str && strcmp (str, "1") == 0) return 1;
15437 static int test_touch_0 (void)
15439 if (test_touch_0_skip ()) {
15440 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_touch_0");
15444 /* InitBasicFS for test_touch_0: create ext2 on /dev/sda1 */
15446 char device[] = "/dev/sda";
15447 device[5] = devchar;
15449 suppress_error = 0;
15450 r = guestfs_blockdev_setrw (g, device);
15456 suppress_error = 0;
15457 r = guestfs_umount_all (g);
15463 suppress_error = 0;
15464 r = guestfs_lvm_remove_all (g);
15469 char device[] = "/dev/sda";
15470 device[5] = devchar;
15471 char lines_0[] = ",";
15477 suppress_error = 0;
15478 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15483 char fstype[] = "ext2";
15484 char device[] = "/dev/sda1";
15485 device[5] = devchar;
15487 suppress_error = 0;
15488 r = guestfs_mkfs (g, fstype, device);
15493 char device[] = "/dev/sda1";
15494 device[5] = devchar;
15495 char mountpoint[] = "/";
15497 suppress_error = 0;
15498 r = guestfs_mount (g, device, mountpoint);
15502 /* TestOutputTrue for touch (0) */
15504 char path[] = "/new";
15506 suppress_error = 0;
15507 r = guestfs_touch (g, path);
15512 char path[] = "/new";
15514 suppress_error = 0;
15515 r = guestfs_exists (g, path);
15519 fprintf (stderr, "test_touch_0: expected true, got false\n");
15526 static int test_sync_0_skip (void)
15530 str = getenv ("SKIP_TEST_SYNC_0");
15531 if (str && strcmp (str, "1") == 0) return 1;
15532 str = getenv ("SKIP_TEST_SYNC");
15533 if (str && strcmp (str, "1") == 0) return 1;
15537 static int test_sync_0 (void)
15539 if (test_sync_0_skip ()) {
15540 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_sync_0");
15544 /* InitNone|InitEmpty for test_sync_0 */
15546 char device[] = "/dev/sda";
15547 device[5] = devchar;
15549 suppress_error = 0;
15550 r = guestfs_blockdev_setrw (g, device);
15556 suppress_error = 0;
15557 r = guestfs_umount_all (g);
15563 suppress_error = 0;
15564 r = guestfs_lvm_remove_all (g);
15568 /* TestRun for sync (0) */
15571 suppress_error = 0;
15572 r = guestfs_sync (g);
15579 static int test_mount_0_skip (void)
15583 str = getenv ("SKIP_TEST_MOUNT_0");
15584 if (str && strcmp (str, "1") == 0) return 1;
15585 str = getenv ("SKIP_TEST_MOUNT");
15586 if (str && strcmp (str, "1") == 0) return 1;
15590 static int test_mount_0 (void)
15592 if (test_mount_0_skip ()) {
15593 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_0");
15597 /* InitNone|InitEmpty for test_mount_0 */
15599 char device[] = "/dev/sda";
15600 device[5] = devchar;
15602 suppress_error = 0;
15603 r = guestfs_blockdev_setrw (g, device);
15609 suppress_error = 0;
15610 r = guestfs_umount_all (g);
15616 suppress_error = 0;
15617 r = guestfs_lvm_remove_all (g);
15621 /* TestOutput for mount (0) */
15622 char expected[] = "new file contents";
15624 char device[] = "/dev/sda";
15625 device[5] = devchar;
15626 char lines_0[] = ",";
15632 suppress_error = 0;
15633 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15638 char fstype[] = "ext2";
15639 char device[] = "/dev/sda1";
15640 device[5] = devchar;
15642 suppress_error = 0;
15643 r = guestfs_mkfs (g, fstype, device);
15648 char device[] = "/dev/sda1";
15649 device[5] = devchar;
15650 char mountpoint[] = "/";
15652 suppress_error = 0;
15653 r = guestfs_mount (g, device, mountpoint);
15658 char path[] = "/new";
15659 char content[] = "new file contents";
15661 suppress_error = 0;
15662 r = guestfs_write_file (g, path, content, 0);
15667 char path[] = "/new";
15669 suppress_error = 0;
15670 r = guestfs_cat (g, path);
15673 if (strcmp (r, expected) != 0) {
15674 fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
15682 int main (int argc, char *argv[])
15686 const char *srcdir;
15687 const char *filename;
15689 int nr_tests, test_num = 0;
15692 no_test_warnings ();
15694 g = guestfs_create ();
15696 printf ("guestfs_create FAILED\n");
15700 guestfs_set_error_handler (g, print_error, NULL);
15702 srcdir = getenv ("srcdir");
15703 if (!srcdir) srcdir = ".";
15705 guestfs_set_path (g, ".");
15707 filename = "test1.img";
15708 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
15713 if (lseek (fd, 524288000, SEEK_SET) == -1) {
15719 if (write (fd, &c, 1) == -1) {
15725 if (close (fd) == -1) {
15730 if (guestfs_add_drive (g, filename) == -1) {
15731 printf ("guestfs_add_drive %s FAILED\n", filename);
15735 filename = "test2.img";
15736 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
15741 if (lseek (fd, 52428800, SEEK_SET) == -1) {
15747 if (write (fd, &c, 1) == -1) {
15753 if (close (fd) == -1) {
15758 if (guestfs_add_drive (g, filename) == -1) {
15759 printf ("guestfs_add_drive %s FAILED\n", filename);
15763 filename = "test3.img";
15764 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
15769 if (lseek (fd, 10485760, SEEK_SET) == -1) {
15775 if (write (fd, &c, 1) == -1) {
15781 if (close (fd) == -1) {
15786 if (guestfs_add_drive (g, filename) == -1) {
15787 printf ("guestfs_add_drive %s FAILED\n", filename);
15791 if (guestfs_launch (g) == -1) {
15792 printf ("guestfs_launch FAILED\n");
15795 if (guestfs_wait_ready (g) == -1) {
15796 printf ("guestfs_wait_ready FAILED\n");
15800 /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
15801 * names. This changed between RHEL 5 and RHEL 6 so we have to
15804 devs = guestfs_list_devices (g);
15805 if (devs == NULL || devs[0] == NULL) {
15806 printf ("guestfs_list_devices FAILED\n");
15809 if (strncmp (devs[0], "/dev/sd", 7) == 0)
15811 else if (strncmp (devs[0], "/dev/hd", 7) == 0)
15814 printf ("guestfs_list_devices returned unexpected string '%s'\n",
15818 for (i = 0; devs[i] != NULL; ++i)
15825 printf ("%3d/%3d test_find_0\n", test_num, nr_tests);
15826 if (test_find_0 () == -1) {
15827 printf ("test_find_0 FAILED\n");
15831 printf ("%3d/%3d test_find_1\n", test_num, nr_tests);
15832 if (test_find_1 () == -1) {
15833 printf ("test_find_1 FAILED\n");
15837 printf ("%3d/%3d test_find_2\n", test_num, nr_tests);
15838 if (test_find_2 () == -1) {
15839 printf ("test_find_2 FAILED\n");
15843 printf ("%3d/%3d test_lvresize_0\n", test_num, nr_tests);
15844 if (test_lvresize_0 () == -1) {
15845 printf ("test_lvresize_0 FAILED\n");
15849 printf ("%3d/%3d test_zerofree_0\n", test_num, nr_tests);
15850 if (test_zerofree_0 () == -1) {
15851 printf ("test_zerofree_0 FAILED\n");
15855 printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
15856 if (test_hexdump_0 () == -1) {
15857 printf ("test_hexdump_0 FAILED\n");
15861 printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
15862 if (test_strings_e_0 () == -1) {
15863 printf ("test_strings_e_0 FAILED\n");
15867 printf ("%3d/%3d test_strings_e_1\n", test_num, nr_tests);
15868 if (test_strings_e_1 () == -1) {
15869 printf ("test_strings_e_1 FAILED\n");
15873 printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
15874 if (test_strings_0 () == -1) {
15875 printf ("test_strings_0 FAILED\n");
15879 printf ("%3d/%3d test_strings_1\n", test_num, nr_tests);
15880 if (test_strings_1 () == -1) {
15881 printf ("test_strings_1 FAILED\n");
15885 printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
15886 if (test_equal_0 () == -1) {
15887 printf ("test_equal_0 FAILED\n");
15891 printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
15892 if (test_equal_1 () == -1) {
15893 printf ("test_equal_1 FAILED\n");
15897 printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
15898 if (test_equal_2 () == -1) {
15899 printf ("test_equal_2 FAILED\n");
15903 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
15904 if (test_ping_daemon_0 () == -1) {
15905 printf ("test_ping_daemon_0 FAILED\n");
15909 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
15910 if (test_dmesg_0 () == -1) {
15911 printf ("test_dmesg_0 FAILED\n");
15915 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
15916 if (test_drop_caches_0 () == -1) {
15917 printf ("test_drop_caches_0 FAILED\n");
15921 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
15922 if (test_mv_0 () == -1) {
15923 printf ("test_mv_0 FAILED\n");
15927 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
15928 if (test_mv_1 () == -1) {
15929 printf ("test_mv_1 FAILED\n");
15933 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
15934 if (test_cp_a_0 () == -1) {
15935 printf ("test_cp_a_0 FAILED\n");
15939 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
15940 if (test_cp_0 () == -1) {
15941 printf ("test_cp_0 FAILED\n");
15945 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
15946 if (test_cp_1 () == -1) {
15947 printf ("test_cp_1 FAILED\n");
15951 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
15952 if (test_cp_2 () == -1) {
15953 printf ("test_cp_2 FAILED\n");
15957 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
15958 if (test_grub_install_0 () == -1) {
15959 printf ("test_grub_install_0 FAILED\n");
15963 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
15964 if (test_zero_0 () == -1) {
15965 printf ("test_zero_0 FAILED\n");
15969 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
15970 if (test_fsck_0 () == -1) {
15971 printf ("test_fsck_0 FAILED\n");
15975 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
15976 if (test_fsck_1 () == -1) {
15977 printf ("test_fsck_1 FAILED\n");
15981 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
15982 if (test_set_e2uuid_0 () == -1) {
15983 printf ("test_set_e2uuid_0 FAILED\n");
15987 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
15988 if (test_set_e2uuid_1 () == -1) {
15989 printf ("test_set_e2uuid_1 FAILED\n");
15993 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
15994 if (test_set_e2uuid_2 () == -1) {
15995 printf ("test_set_e2uuid_2 FAILED\n");
15999 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
16000 if (test_set_e2uuid_3 () == -1) {
16001 printf ("test_set_e2uuid_3 FAILED\n");
16005 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
16006 if (test_set_e2label_0 () == -1) {
16007 printf ("test_set_e2label_0 FAILED\n");
16011 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
16012 if (test_pvremove_0 () == -1) {
16013 printf ("test_pvremove_0 FAILED\n");
16017 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
16018 if (test_pvremove_1 () == -1) {
16019 printf ("test_pvremove_1 FAILED\n");
16023 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
16024 if (test_pvremove_2 () == -1) {
16025 printf ("test_pvremove_2 FAILED\n");
16029 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
16030 if (test_vgremove_0 () == -1) {
16031 printf ("test_vgremove_0 FAILED\n");
16035 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
16036 if (test_vgremove_1 () == -1) {
16037 printf ("test_vgremove_1 FAILED\n");
16041 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
16042 if (test_lvremove_0 () == -1) {
16043 printf ("test_lvremove_0 FAILED\n");
16047 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
16048 if (test_lvremove_1 () == -1) {
16049 printf ("test_lvremove_1 FAILED\n");
16053 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
16054 if (test_lvremove_2 () == -1) {
16055 printf ("test_lvremove_2 FAILED\n");
16059 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
16060 if (test_mount_ro_0 () == -1) {
16061 printf ("test_mount_ro_0 FAILED\n");
16065 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
16066 if (test_mount_ro_1 () == -1) {
16067 printf ("test_mount_ro_1 FAILED\n");
16071 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
16072 if (test_tgz_in_0 () == -1) {
16073 printf ("test_tgz_in_0 FAILED\n");
16077 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
16078 if (test_tar_in_0 () == -1) {
16079 printf ("test_tar_in_0 FAILED\n");
16083 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
16084 if (test_checksum_0 () == -1) {
16085 printf ("test_checksum_0 FAILED\n");
16089 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
16090 if (test_checksum_1 () == -1) {
16091 printf ("test_checksum_1 FAILED\n");
16095 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
16096 if (test_checksum_2 () == -1) {
16097 printf ("test_checksum_2 FAILED\n");
16101 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
16102 if (test_checksum_3 () == -1) {
16103 printf ("test_checksum_3 FAILED\n");
16107 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
16108 if (test_checksum_4 () == -1) {
16109 printf ("test_checksum_4 FAILED\n");
16113 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
16114 if (test_checksum_5 () == -1) {
16115 printf ("test_checksum_5 FAILED\n");
16119 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
16120 if (test_checksum_6 () == -1) {
16121 printf ("test_checksum_6 FAILED\n");
16125 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
16126 if (test_checksum_7 () == -1) {
16127 printf ("test_checksum_7 FAILED\n");
16131 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
16132 if (test_download_0 () == -1) {
16133 printf ("test_download_0 FAILED\n");
16137 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
16138 if (test_upload_0 () == -1) {
16139 printf ("test_upload_0 FAILED\n");
16143 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
16144 if (test_blockdev_rereadpt_0 () == -1) {
16145 printf ("test_blockdev_rereadpt_0 FAILED\n");
16149 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
16150 if (test_blockdev_flushbufs_0 () == -1) {
16151 printf ("test_blockdev_flushbufs_0 FAILED\n");
16155 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
16156 if (test_blockdev_getsize64_0 () == -1) {
16157 printf ("test_blockdev_getsize64_0 FAILED\n");
16161 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
16162 if (test_blockdev_getsz_0 () == -1) {
16163 printf ("test_blockdev_getsz_0 FAILED\n");
16167 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
16168 if (test_blockdev_getbsz_0 () == -1) {
16169 printf ("test_blockdev_getbsz_0 FAILED\n");
16173 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
16174 if (test_blockdev_getss_0 () == -1) {
16175 printf ("test_blockdev_getss_0 FAILED\n");
16179 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
16180 if (test_blockdev_getro_0 () == -1) {
16181 printf ("test_blockdev_getro_0 FAILED\n");
16185 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
16186 if (test_blockdev_setrw_0 () == -1) {
16187 printf ("test_blockdev_setrw_0 FAILED\n");
16191 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
16192 if (test_blockdev_setro_0 () == -1) {
16193 printf ("test_blockdev_setro_0 FAILED\n");
16197 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
16198 if (test_statvfs_0 () == -1) {
16199 printf ("test_statvfs_0 FAILED\n");
16203 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
16204 if (test_lstat_0 () == -1) {
16205 printf ("test_lstat_0 FAILED\n");
16209 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
16210 if (test_stat_0 () == -1) {
16211 printf ("test_stat_0 FAILED\n");
16215 printf ("%3d/%3d test_command_lines_0\n", test_num, nr_tests);
16216 if (test_command_lines_0 () == -1) {
16217 printf ("test_command_lines_0 FAILED\n");
16221 printf ("%3d/%3d test_command_lines_1\n", test_num, nr_tests);
16222 if (test_command_lines_1 () == -1) {
16223 printf ("test_command_lines_1 FAILED\n");
16227 printf ("%3d/%3d test_command_lines_2\n", test_num, nr_tests);
16228 if (test_command_lines_2 () == -1) {
16229 printf ("test_command_lines_2 FAILED\n");
16233 printf ("%3d/%3d test_command_lines_3\n", test_num, nr_tests);
16234 if (test_command_lines_3 () == -1) {
16235 printf ("test_command_lines_3 FAILED\n");
16239 printf ("%3d/%3d test_command_lines_4\n", test_num, nr_tests);
16240 if (test_command_lines_4 () == -1) {
16241 printf ("test_command_lines_4 FAILED\n");
16245 printf ("%3d/%3d test_command_lines_5\n", test_num, nr_tests);
16246 if (test_command_lines_5 () == -1) {
16247 printf ("test_command_lines_5 FAILED\n");
16251 printf ("%3d/%3d test_command_lines_6\n", test_num, nr_tests);
16252 if (test_command_lines_6 () == -1) {
16253 printf ("test_command_lines_6 FAILED\n");
16257 printf ("%3d/%3d test_command_lines_7\n", test_num, nr_tests);
16258 if (test_command_lines_7 () == -1) {
16259 printf ("test_command_lines_7 FAILED\n");
16263 printf ("%3d/%3d test_command_lines_8\n", test_num, nr_tests);
16264 if (test_command_lines_8 () == -1) {
16265 printf ("test_command_lines_8 FAILED\n");
16269 printf ("%3d/%3d test_command_lines_9\n", test_num, nr_tests);
16270 if (test_command_lines_9 () == -1) {
16271 printf ("test_command_lines_9 FAILED\n");
16275 printf ("%3d/%3d test_command_lines_10\n", test_num, nr_tests);
16276 if (test_command_lines_10 () == -1) {
16277 printf ("test_command_lines_10 FAILED\n");
16281 printf ("%3d/%3d test_command_0\n", test_num, nr_tests);
16282 if (test_command_0 () == -1) {
16283 printf ("test_command_0 FAILED\n");
16287 printf ("%3d/%3d test_command_1\n", test_num, nr_tests);
16288 if (test_command_1 () == -1) {
16289 printf ("test_command_1 FAILED\n");
16293 printf ("%3d/%3d test_command_2\n", test_num, nr_tests);
16294 if (test_command_2 () == -1) {
16295 printf ("test_command_2 FAILED\n");
16299 printf ("%3d/%3d test_command_3\n", test_num, nr_tests);
16300 if (test_command_3 () == -1) {
16301 printf ("test_command_3 FAILED\n");
16305 printf ("%3d/%3d test_command_4\n", test_num, nr_tests);
16306 if (test_command_4 () == -1) {
16307 printf ("test_command_4 FAILED\n");
16311 printf ("%3d/%3d test_command_5\n", test_num, nr_tests);
16312 if (test_command_5 () == -1) {
16313 printf ("test_command_5 FAILED\n");
16317 printf ("%3d/%3d test_command_6\n", test_num, nr_tests);
16318 if (test_command_6 () == -1) {
16319 printf ("test_command_6 FAILED\n");
16323 printf ("%3d/%3d test_command_7\n", test_num, nr_tests);
16324 if (test_command_7 () == -1) {
16325 printf ("test_command_7 FAILED\n");
16329 printf ("%3d/%3d test_command_8\n", test_num, nr_tests);
16330 if (test_command_8 () == -1) {
16331 printf ("test_command_8 FAILED\n");
16335 printf ("%3d/%3d test_command_9\n", test_num, nr_tests);
16336 if (test_command_9 () == -1) {
16337 printf ("test_command_9 FAILED\n");
16341 printf ("%3d/%3d test_command_10\n", test_num, nr_tests);
16342 if (test_command_10 () == -1) {
16343 printf ("test_command_10 FAILED\n");
16347 printf ("%3d/%3d test_command_11\n", test_num, nr_tests);
16348 if (test_command_11 () == -1) {
16349 printf ("test_command_11 FAILED\n");
16353 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
16354 if (test_file_0 () == -1) {
16355 printf ("test_file_0 FAILED\n");
16359 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
16360 if (test_file_1 () == -1) {
16361 printf ("test_file_1 FAILED\n");
16365 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
16366 if (test_file_2 () == -1) {
16367 printf ("test_file_2 FAILED\n");
16371 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
16372 if (test_umount_all_0 () == -1) {
16373 printf ("test_umount_all_0 FAILED\n");
16377 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
16378 if (test_umount_all_1 () == -1) {
16379 printf ("test_umount_all_1 FAILED\n");
16383 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
16384 if (test_mounts_0 () == -1) {
16385 printf ("test_mounts_0 FAILED\n");
16389 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
16390 if (test_umount_0 () == -1) {
16391 printf ("test_umount_0 FAILED\n");
16395 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
16396 if (test_umount_1 () == -1) {
16397 printf ("test_umount_1 FAILED\n");
16401 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
16402 if (test_write_file_0 () == -1) {
16403 printf ("test_write_file_0 FAILED\n");
16407 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
16408 if (test_write_file_1 () == -1) {
16409 printf ("test_write_file_1 FAILED\n");
16413 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
16414 if (test_write_file_2 () == -1) {
16415 printf ("test_write_file_2 FAILED\n");
16419 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
16420 if (test_write_file_3 () == -1) {
16421 printf ("test_write_file_3 FAILED\n");
16425 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
16426 if (test_write_file_4 () == -1) {
16427 printf ("test_write_file_4 FAILED\n");
16431 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
16432 if (test_write_file_5 () == -1) {
16433 printf ("test_write_file_5 FAILED\n");
16437 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
16438 if (test_mkfs_0 () == -1) {
16439 printf ("test_mkfs_0 FAILED\n");
16443 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
16444 if (test_lvcreate_0 () == -1) {
16445 printf ("test_lvcreate_0 FAILED\n");
16449 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
16450 if (test_vgcreate_0 () == -1) {
16451 printf ("test_vgcreate_0 FAILED\n");
16455 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
16456 if (test_pvcreate_0 () == -1) {
16457 printf ("test_pvcreate_0 FAILED\n");
16461 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
16462 if (test_is_dir_0 () == -1) {
16463 printf ("test_is_dir_0 FAILED\n");
16467 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
16468 if (test_is_dir_1 () == -1) {
16469 printf ("test_is_dir_1 FAILED\n");
16473 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
16474 if (test_is_file_0 () == -1) {
16475 printf ("test_is_file_0 FAILED\n");
16479 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
16480 if (test_is_file_1 () == -1) {
16481 printf ("test_is_file_1 FAILED\n");
16485 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
16486 if (test_exists_0 () == -1) {
16487 printf ("test_exists_0 FAILED\n");
16491 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
16492 if (test_exists_1 () == -1) {
16493 printf ("test_exists_1 FAILED\n");
16497 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
16498 if (test_mkdir_p_0 () == -1) {
16499 printf ("test_mkdir_p_0 FAILED\n");
16503 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
16504 if (test_mkdir_p_1 () == -1) {
16505 printf ("test_mkdir_p_1 FAILED\n");
16509 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
16510 if (test_mkdir_p_2 () == -1) {
16511 printf ("test_mkdir_p_2 FAILED\n");
16515 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
16516 if (test_mkdir_0 () == -1) {
16517 printf ("test_mkdir_0 FAILED\n");
16521 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
16522 if (test_mkdir_1 () == -1) {
16523 printf ("test_mkdir_1 FAILED\n");
16527 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
16528 if (test_rm_rf_0 () == -1) {
16529 printf ("test_rm_rf_0 FAILED\n");
16533 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
16534 if (test_rmdir_0 () == -1) {
16535 printf ("test_rmdir_0 FAILED\n");
16539 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
16540 if (test_rmdir_1 () == -1) {
16541 printf ("test_rmdir_1 FAILED\n");
16545 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
16546 if (test_rmdir_2 () == -1) {
16547 printf ("test_rmdir_2 FAILED\n");
16551 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
16552 if (test_rm_0 () == -1) {
16553 printf ("test_rm_0 FAILED\n");
16557 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
16558 if (test_rm_1 () == -1) {
16559 printf ("test_rm_1 FAILED\n");
16563 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
16564 if (test_rm_2 () == -1) {
16565 printf ("test_rm_2 FAILED\n");
16569 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
16570 if (test_read_lines_0 () == -1) {
16571 printf ("test_read_lines_0 FAILED\n");
16575 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
16576 if (test_read_lines_1 () == -1) {
16577 printf ("test_read_lines_1 FAILED\n");
16581 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
16582 if (test_lvs_0 () == -1) {
16583 printf ("test_lvs_0 FAILED\n");
16587 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
16588 if (test_lvs_1 () == -1) {
16589 printf ("test_lvs_1 FAILED\n");
16593 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
16594 if (test_vgs_0 () == -1) {
16595 printf ("test_vgs_0 FAILED\n");
16599 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
16600 if (test_vgs_1 () == -1) {
16601 printf ("test_vgs_1 FAILED\n");
16605 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
16606 if (test_pvs_0 () == -1) {
16607 printf ("test_pvs_0 FAILED\n");
16611 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
16612 if (test_pvs_1 () == -1) {
16613 printf ("test_pvs_1 FAILED\n");
16617 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
16618 if (test_list_partitions_0 () == -1) {
16619 printf ("test_list_partitions_0 FAILED\n");
16623 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
16624 if (test_list_partitions_1 () == -1) {
16625 printf ("test_list_partitions_1 FAILED\n");
16629 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
16630 if (test_list_devices_0 () == -1) {
16631 printf ("test_list_devices_0 FAILED\n");
16635 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
16636 if (test_ls_0 () == -1) {
16637 printf ("test_ls_0 FAILED\n");
16641 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
16642 if (test_cat_0 () == -1) {
16643 printf ("test_cat_0 FAILED\n");
16647 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
16648 if (test_touch_0 () == -1) {
16649 printf ("test_touch_0 FAILED\n");
16653 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
16654 if (test_sync_0 () == -1) {
16655 printf ("test_sync_0 FAILED\n");
16659 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
16660 if (test_mount_0 () == -1) {
16661 printf ("test_mount_0 FAILED\n");
16666 unlink ("test1.img");
16667 unlink ("test2.img");
16668 unlink ("test3.img");
16671 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);