1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
32 static int suppress_error = 0;
34 static void print_error (guestfs_h *g, void *data, const char *msg)
37 fprintf (stderr, "%s\n", msg);
40 static void print_strings (char * const * const argv)
44 for (argc = 0; argv[argc] != NULL; ++argc)
45 printf ("\t%s\n", argv[argc]);
49 static void print_table (char * const * const argv)
53 for (i = 0; argv[i] != NULL; i += 2)
54 printf ("%s: %s\n", argv[i], argv[i+1]);
58 static void no_test_warnings (void)
60 fprintf (stderr, "warning: \"guestfs_test0\" has no tests\n");
61 fprintf (stderr, "warning: \"guestfs_test0rint\" has no tests\n");
62 fprintf (stderr, "warning: \"guestfs_test0rinterr\" has no tests\n");
63 fprintf (stderr, "warning: \"guestfs_test0rint64\" has no tests\n");
64 fprintf (stderr, "warning: \"guestfs_test0rint64err\" has no tests\n");
65 fprintf (stderr, "warning: \"guestfs_test0rbool\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_test0rboolerr\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_test0rconststring\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_test0rconststringerr\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_test0rstring\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_test0rstringerr\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_test0rstringlist\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_test0rstringlisterr\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_test0rintbool\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_test0rintboolerr\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_test0rpvlist\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_test0rpvlisterr\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_test0rvglist\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_test0rvglisterr\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_test0rlvlist\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_test0rlvlisterr\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_test0rstat\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_test0rstaterr\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_test0rstatvfs\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_test0rstatvfserr\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_test0rhashtable\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_test0rhashtableerr\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_add_drive_ro\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_set_append\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_get_append\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
111 fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
112 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
113 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
114 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
115 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
116 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
117 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
118 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
119 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
120 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
121 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
122 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
123 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
124 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
125 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
126 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
127 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
128 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
129 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
130 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
131 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
132 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
133 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
134 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
135 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
136 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
137 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
138 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
139 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
140 fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
141 fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
142 fprintf (stderr, "warning: \"guestfs_pvresize\" has no tests\n");
143 fprintf (stderr, "warning: \"guestfs_sfdisk_N\" has no tests\n");
144 fprintf (stderr, "warning: \"guestfs_sfdisk_l\" has no tests\n");
145 fprintf (stderr, "warning: \"guestfs_sfdisk_kernel_geometry\" has no tests\n");
146 fprintf (stderr, "warning: \"guestfs_sfdisk_disk_geometry\" has no tests\n");
147 fprintf (stderr, "warning: \"guestfs_vg_activate_all\" has no tests\n");
148 fprintf (stderr, "warning: \"guestfs_vg_activate\" has no tests\n");
149 fprintf (stderr, "warning: \"guestfs_resize2fs\" has no tests\n");
150 fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
151 fprintf (stderr, "warning: \"guestfs_sh\" has no tests\n");
152 fprintf (stderr, "warning: \"guestfs_sh_lines\" has no tests\n");
153 fprintf (stderr, "warning: \"guestfs_scrub_freespace\" has no tests\n");
156 static int test_mkdtemp_0_skip (void)
160 str = getenv ("SKIP_TEST_MKDTEMP_0");
161 if (str && strcmp (str, "1") == 0) return 1;
162 str = getenv ("SKIP_TEST_MKDTEMP");
163 if (str && strcmp (str, "1") == 0) return 1;
167 static int test_mkdtemp_0 (void)
169 if (test_mkdtemp_0_skip ()) {
170 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdtemp_0");
174 /* InitBasicFS for test_mkdtemp_0: create ext2 on /dev/sda1 */
176 char device[] = "/dev/sda";
179 r = guestfs_blockdev_setrw (g, device);
186 r = guestfs_umount_all (g);
193 r = guestfs_lvm_remove_all (g);
198 char device[] = "/dev/sda";
199 char lines_0[] = ",";
206 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
211 char fstype[] = "ext2";
212 char device[] = "/dev/sda1";
215 r = guestfs_mkfs (g, fstype, device);
220 char device[] = "/dev/sda1";
221 char mountpoint[] = "/";
224 r = guestfs_mount (g, device, mountpoint);
228 /* TestRun for mkdtemp (0) */
230 char path[] = "/tmp";
233 r = guestfs_mkdir (g, path);
238 char template[] = "/tmp/tmpXXXXXX";
241 r = guestfs_mkdtemp (g, template);
249 static int test_scrub_file_0_skip (void)
253 str = getenv ("SKIP_TEST_SCRUB_FILE_0");
254 if (str && strcmp (str, "1") == 0) return 1;
255 str = getenv ("SKIP_TEST_SCRUB_FILE");
256 if (str && strcmp (str, "1") == 0) return 1;
260 static int test_scrub_file_0 (void)
262 if (test_scrub_file_0_skip ()) {
263 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_scrub_file_0");
267 /* InitBasicFS for test_scrub_file_0: create ext2 on /dev/sda1 */
269 char device[] = "/dev/sda";
272 r = guestfs_blockdev_setrw (g, device);
279 r = guestfs_umount_all (g);
286 r = guestfs_lvm_remove_all (g);
291 char device[] = "/dev/sda";
292 char lines_0[] = ",";
299 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
304 char fstype[] = "ext2";
305 char device[] = "/dev/sda1";
308 r = guestfs_mkfs (g, fstype, device);
313 char device[] = "/dev/sda1";
314 char mountpoint[] = "/";
317 r = guestfs_mount (g, device, mountpoint);
321 /* TestRun for scrub_file (0) */
323 char path[] = "/file";
324 char content[] = "content";
327 r = guestfs_write_file (g, path, content, 0);
332 char file[] = "/file";
335 r = guestfs_scrub_file (g, file);
342 static int test_scrub_device_0_skip (void)
346 str = getenv ("SKIP_TEST_SCRUB_DEVICE_0");
347 if (str && strcmp (str, "1") == 0) return 1;
348 str = getenv ("SKIP_TEST_SCRUB_DEVICE");
349 if (str && strcmp (str, "1") == 0) return 1;
353 static int test_scrub_device_0 (void)
355 if (test_scrub_device_0_skip ()) {
356 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_scrub_device_0");
360 /* InitNone|InitEmpty for test_scrub_device_0 */
362 char device[] = "/dev/sda";
365 r = guestfs_blockdev_setrw (g, device);
372 r = guestfs_umount_all (g);
379 r = guestfs_lvm_remove_all (g);
383 /* TestRun for scrub_device (0) */
385 char device[] = "/dev/sdc";
388 r = guestfs_scrub_device (g, device);
395 static int test_glob_expand_0_skip (void)
399 str = getenv ("SKIP_TEST_GLOB_EXPAND_0");
400 if (str && strcmp (str, "1") == 0) return 1;
401 str = getenv ("SKIP_TEST_GLOB_EXPAND");
402 if (str && strcmp (str, "1") == 0) return 1;
406 static int test_glob_expand_0 (void)
408 if (test_glob_expand_0_skip ()) {
409 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_glob_expand_0");
413 /* InitBasicFS for test_glob_expand_0: create ext2 on /dev/sda1 */
415 char device[] = "/dev/sda";
418 r = guestfs_blockdev_setrw (g, device);
425 r = guestfs_umount_all (g);
432 r = guestfs_lvm_remove_all (g);
437 char device[] = "/dev/sda";
438 char lines_0[] = ",";
445 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
450 char fstype[] = "ext2";
451 char device[] = "/dev/sda1";
454 r = guestfs_mkfs (g, fstype, device);
459 char device[] = "/dev/sda1";
460 char mountpoint[] = "/";
463 r = guestfs_mount (g, device, mountpoint);
467 /* TestOutputList for glob_expand (0) */
469 char path[] = "/a/b/c";
472 r = guestfs_mkdir_p (g, path);
477 char path[] = "/a/b/c/d";
480 r = guestfs_touch (g, path);
485 char path[] = "/a/b/c/e";
488 r = guestfs_touch (g, path);
493 char pattern[] = "/a/b/c/*";
497 r = guestfs_glob_expand (g, pattern);
501 fprintf (stderr, "test_glob_expand_0: short list returned from command\n");
506 char expected[] = "/a/b/c/d";
507 if (strcmp (r[0], expected) != 0) {
508 fprintf (stderr, "test_glob_expand_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
513 fprintf (stderr, "test_glob_expand_0: short list returned from command\n");
518 char expected[] = "/a/b/c/e";
519 if (strcmp (r[1], expected) != 0) {
520 fprintf (stderr, "test_glob_expand_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
525 fprintf (stderr, "test_glob_expand_0: extra elements returned from command\n");
529 for (i = 0; r[i] != NULL; ++i)
536 static int test_glob_expand_1_skip (void)
540 str = getenv ("SKIP_TEST_GLOB_EXPAND_1");
541 if (str && strcmp (str, "1") == 0) return 1;
542 str = getenv ("SKIP_TEST_GLOB_EXPAND");
543 if (str && strcmp (str, "1") == 0) return 1;
547 static int test_glob_expand_1 (void)
549 if (test_glob_expand_1_skip ()) {
550 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_glob_expand_1");
554 /* InitBasicFS for test_glob_expand_1: create ext2 on /dev/sda1 */
556 char device[] = "/dev/sda";
559 r = guestfs_blockdev_setrw (g, device);
566 r = guestfs_umount_all (g);
573 r = guestfs_lvm_remove_all (g);
578 char device[] = "/dev/sda";
579 char lines_0[] = ",";
586 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
591 char fstype[] = "ext2";
592 char device[] = "/dev/sda1";
595 r = guestfs_mkfs (g, fstype, device);
600 char device[] = "/dev/sda1";
601 char mountpoint[] = "/";
604 r = guestfs_mount (g, device, mountpoint);
608 /* TestOutputList for glob_expand (1) */
610 char path[] = "/a/b/c";
613 r = guestfs_mkdir_p (g, path);
618 char path[] = "/a/b/c/d";
621 r = guestfs_touch (g, path);
626 char path[] = "/a/b/c/e";
629 r = guestfs_touch (g, path);
634 char pattern[] = "/a/*/c/*";
638 r = guestfs_glob_expand (g, pattern);
642 fprintf (stderr, "test_glob_expand_1: short list returned from command\n");
647 char expected[] = "/a/b/c/d";
648 if (strcmp (r[0], expected) != 0) {
649 fprintf (stderr, "test_glob_expand_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
654 fprintf (stderr, "test_glob_expand_1: short list returned from command\n");
659 char expected[] = "/a/b/c/e";
660 if (strcmp (r[1], expected) != 0) {
661 fprintf (stderr, "test_glob_expand_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
666 fprintf (stderr, "test_glob_expand_1: extra elements returned from command\n");
670 for (i = 0; r[i] != NULL; ++i)
677 static int test_glob_expand_2_skip (void)
681 str = getenv ("SKIP_TEST_GLOB_EXPAND_2");
682 if (str && strcmp (str, "1") == 0) return 1;
683 str = getenv ("SKIP_TEST_GLOB_EXPAND");
684 if (str && strcmp (str, "1") == 0) return 1;
688 static int test_glob_expand_2 (void)
690 if (test_glob_expand_2_skip ()) {
691 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_glob_expand_2");
695 /* InitBasicFS for test_glob_expand_2: create ext2 on /dev/sda1 */
697 char device[] = "/dev/sda";
700 r = guestfs_blockdev_setrw (g, device);
707 r = guestfs_umount_all (g);
714 r = guestfs_lvm_remove_all (g);
719 char device[] = "/dev/sda";
720 char lines_0[] = ",";
727 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
732 char fstype[] = "ext2";
733 char device[] = "/dev/sda1";
736 r = guestfs_mkfs (g, fstype, device);
741 char device[] = "/dev/sda1";
742 char mountpoint[] = "/";
745 r = guestfs_mount (g, device, mountpoint);
749 /* TestOutputList for glob_expand (2) */
751 char path[] = "/a/b/c";
754 r = guestfs_mkdir_p (g, path);
759 char path[] = "/a/b/c/d";
762 r = guestfs_touch (g, path);
767 char path[] = "/a/b/c/e";
770 r = guestfs_touch (g, path);
775 char pattern[] = "/a/*/x/*";
779 r = guestfs_glob_expand (g, pattern);
783 fprintf (stderr, "test_glob_expand_2: extra elements returned from command\n");
787 for (i = 0; r[i] != NULL; ++i)
794 static int test_ntfs_3g_probe_0_skip (void)
798 str = getenv ("SKIP_TEST_NTFS_3G_PROBE_0");
799 if (str && strcmp (str, "1") == 0) return 1;
800 str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
801 if (str && strcmp (str, "1") == 0) return 1;
805 static int test_ntfs_3g_probe_0 (void)
807 if (test_ntfs_3g_probe_0_skip ()) {
808 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ntfs_3g_probe_0");
812 /* InitNone|InitEmpty for test_ntfs_3g_probe_0 */
814 char device[] = "/dev/sda";
817 r = guestfs_blockdev_setrw (g, device);
824 r = guestfs_umount_all (g);
831 r = guestfs_lvm_remove_all (g);
835 /* TestOutputInt for ntfs_3g_probe (0) */
837 char device[] = "/dev/sda";
838 char lines_0[] = ",";
845 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
850 char fstype[] = "ntfs";
851 char device[] = "/dev/sda1";
854 r = guestfs_mkfs (g, fstype, device);
859 char device[] = "/dev/sda1";
862 r = guestfs_ntfs_3g_probe (g, 1, device);
866 fprintf (stderr, "test_ntfs_3g_probe_0: expected 0 but got %d\n", (int) r);
873 static int test_ntfs_3g_probe_1_skip (void)
877 str = getenv ("SKIP_TEST_NTFS_3G_PROBE_1");
878 if (str && strcmp (str, "1") == 0) return 1;
879 str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
880 if (str && strcmp (str, "1") == 0) return 1;
884 static int test_ntfs_3g_probe_1 (void)
886 if (test_ntfs_3g_probe_1_skip ()) {
887 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ntfs_3g_probe_1");
891 /* InitNone|InitEmpty for test_ntfs_3g_probe_1 */
893 char device[] = "/dev/sda";
896 r = guestfs_blockdev_setrw (g, device);
903 r = guestfs_umount_all (g);
910 r = guestfs_lvm_remove_all (g);
914 /* TestOutputInt for ntfs_3g_probe (1) */
916 char device[] = "/dev/sda";
917 char lines_0[] = ",";
924 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
929 char fstype[] = "ext2";
930 char device[] = "/dev/sda1";
933 r = guestfs_mkfs (g, fstype, device);
938 char device[] = "/dev/sda1";
941 r = guestfs_ntfs_3g_probe (g, 1, device);
945 fprintf (stderr, "test_ntfs_3g_probe_1: expected 12 but got %d\n", (int) r);
952 static int test_sleep_0_skip (void)
956 str = getenv ("SKIP_TEST_SLEEP_0");
957 if (str && strcmp (str, "1") == 0) return 1;
958 str = getenv ("SKIP_TEST_SLEEP");
959 if (str && strcmp (str, "1") == 0) return 1;
963 static int test_sleep_0 (void)
965 if (test_sleep_0_skip ()) {
966 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_sleep_0");
970 /* InitNone|InitEmpty for test_sleep_0 */
972 char device[] = "/dev/sda";
975 r = guestfs_blockdev_setrw (g, device);
982 r = guestfs_umount_all (g);
989 r = guestfs_lvm_remove_all (g);
993 /* TestRun for sleep (0) */
997 r = guestfs_sleep (g, 1);
1004 static int test_find_0_skip (void)
1008 str = getenv ("SKIP_TEST_FIND_0");
1009 if (str && strcmp (str, "1") == 0) return 1;
1010 str = getenv ("SKIP_TEST_FIND");
1011 if (str && strcmp (str, "1") == 0) return 1;
1015 static int test_find_0 (void)
1017 if (test_find_0_skip ()) {
1018 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_0");
1022 /* InitBasicFS for test_find_0: create ext2 on /dev/sda1 */
1024 char device[] = "/dev/sda";
1027 r = guestfs_blockdev_setrw (g, device);
1034 r = guestfs_umount_all (g);
1041 r = guestfs_lvm_remove_all (g);
1046 char device[] = "/dev/sda";
1047 char lines_0[] = ",";
1054 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1059 char fstype[] = "ext2";
1060 char device[] = "/dev/sda1";
1063 r = guestfs_mkfs (g, fstype, device);
1068 char device[] = "/dev/sda1";
1069 char mountpoint[] = "/";
1072 r = guestfs_mount (g, device, mountpoint);
1076 /* TestOutputList for find (0) */
1078 char directory[] = "/";
1082 r = guestfs_find (g, directory);
1086 fprintf (stderr, "test_find_0: short list returned from command\n");
1091 char expected[] = "lost+found";
1092 if (strcmp (r[0], expected) != 0) {
1093 fprintf (stderr, "test_find_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
1098 fprintf (stderr, "test_find_0: extra elements returned from command\n");
1102 for (i = 0; r[i] != NULL; ++i)
1109 static int test_find_1_skip (void)
1113 str = getenv ("SKIP_TEST_FIND_1");
1114 if (str && strcmp (str, "1") == 0) return 1;
1115 str = getenv ("SKIP_TEST_FIND");
1116 if (str && strcmp (str, "1") == 0) return 1;
1120 static int test_find_1 (void)
1122 if (test_find_1_skip ()) {
1123 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_1");
1127 /* InitBasicFS for test_find_1: create ext2 on /dev/sda1 */
1129 char device[] = "/dev/sda";
1132 r = guestfs_blockdev_setrw (g, device);
1139 r = guestfs_umount_all (g);
1146 r = guestfs_lvm_remove_all (g);
1151 char device[] = "/dev/sda";
1152 char lines_0[] = ",";
1159 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1164 char fstype[] = "ext2";
1165 char device[] = "/dev/sda1";
1168 r = guestfs_mkfs (g, fstype, device);
1173 char device[] = "/dev/sda1";
1174 char mountpoint[] = "/";
1177 r = guestfs_mount (g, device, mountpoint);
1181 /* TestOutputList for find (1) */
1186 r = guestfs_touch (g, path);
1194 r = guestfs_mkdir (g, path);
1199 char path[] = "/b/c";
1202 r = guestfs_touch (g, path);
1207 char directory[] = "/";
1211 r = guestfs_find (g, directory);
1215 fprintf (stderr, "test_find_1: short list returned from command\n");
1220 char expected[] = "a";
1221 if (strcmp (r[0], expected) != 0) {
1222 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
1227 fprintf (stderr, "test_find_1: short list returned from command\n");
1232 char expected[] = "b";
1233 if (strcmp (r[1], expected) != 0) {
1234 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
1239 fprintf (stderr, "test_find_1: short list returned from command\n");
1244 char expected[] = "b/c";
1245 if (strcmp (r[2], expected) != 0) {
1246 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
1251 fprintf (stderr, "test_find_1: short list returned from command\n");
1256 char expected[] = "lost+found";
1257 if (strcmp (r[3], expected) != 0) {
1258 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[3]);
1263 fprintf (stderr, "test_find_1: extra elements returned from command\n");
1267 for (i = 0; r[i] != NULL; ++i)
1274 static int test_find_2_skip (void)
1278 str = getenv ("SKIP_TEST_FIND_2");
1279 if (str && strcmp (str, "1") == 0) return 1;
1280 str = getenv ("SKIP_TEST_FIND");
1281 if (str && strcmp (str, "1") == 0) return 1;
1285 static int test_find_2 (void)
1287 if (test_find_2_skip ()) {
1288 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_2");
1292 /* InitBasicFS for test_find_2: create ext2 on /dev/sda1 */
1294 char device[] = "/dev/sda";
1297 r = guestfs_blockdev_setrw (g, device);
1304 r = guestfs_umount_all (g);
1311 r = guestfs_lvm_remove_all (g);
1316 char device[] = "/dev/sda";
1317 char lines_0[] = ",";
1324 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1329 char fstype[] = "ext2";
1330 char device[] = "/dev/sda1";
1333 r = guestfs_mkfs (g, fstype, device);
1338 char device[] = "/dev/sda1";
1339 char mountpoint[] = "/";
1342 r = guestfs_mount (g, device, mountpoint);
1346 /* TestOutputList for find (2) */
1348 char path[] = "/a/b/c";
1351 r = guestfs_mkdir_p (g, path);
1356 char path[] = "/a/b/c/d";
1359 r = guestfs_touch (g, path);
1364 char directory[] = "/a/b/";
1368 r = guestfs_find (g, directory);
1372 fprintf (stderr, "test_find_2: short list returned from command\n");
1377 char expected[] = "c";
1378 if (strcmp (r[0], expected) != 0) {
1379 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
1384 fprintf (stderr, "test_find_2: short list returned from command\n");
1389 char expected[] = "c/d";
1390 if (strcmp (r[1], expected) != 0) {
1391 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
1396 fprintf (stderr, "test_find_2: extra elements returned from command\n");
1400 for (i = 0; r[i] != NULL; ++i)
1407 static int test_lvresize_0_skip (void)
1411 str = getenv ("SKIP_TEST_LVRESIZE_0");
1412 if (str && strcmp (str, "1") == 0) return 1;
1413 str = getenv ("SKIP_TEST_LVRESIZE");
1414 if (str && strcmp (str, "1") == 0) return 1;
1418 static int test_lvresize_0 (void)
1420 if (test_lvresize_0_skip ()) {
1421 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvresize_0");
1425 /* InitNone|InitEmpty for test_lvresize_0 */
1427 char device[] = "/dev/sda";
1430 r = guestfs_blockdev_setrw (g, device);
1437 r = guestfs_umount_all (g);
1444 r = guestfs_lvm_remove_all (g);
1448 /* TestOutput for lvresize (0) */
1449 char expected[] = "test content";
1451 char device[] = "/dev/sda";
1452 char lines_0[] = ",";
1459 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1464 char device[] = "/dev/sda1";
1467 r = guestfs_pvcreate (g, device);
1472 char volgroup[] = "VG";
1473 char physvols_0[] = "/dev/sda1";
1474 char *physvols[] = {
1480 r = guestfs_vgcreate (g, volgroup, physvols);
1485 char logvol[] = "LV";
1486 char volgroup[] = "VG";
1489 r = guestfs_lvcreate (g, logvol, volgroup, 10);
1494 char fstype[] = "ext2";
1495 char device[] = "/dev/VG/LV";
1498 r = guestfs_mkfs (g, fstype, device);
1503 char device[] = "/dev/VG/LV";
1504 char mountpoint[] = "/";
1507 r = guestfs_mount (g, device, mountpoint);
1512 char path[] = "/new";
1513 char content[] = "test content";
1516 r = guestfs_write_file (g, path, content, 0);
1521 char pathordevice[] = "/";
1524 r = guestfs_umount (g, pathordevice);
1529 char device[] = "/dev/VG/LV";
1532 r = guestfs_lvresize (g, device, 20);
1537 char device[] = "/dev/VG/LV";
1540 r = guestfs_e2fsck_f (g, device);
1545 char device[] = "/dev/VG/LV";
1548 r = guestfs_resize2fs (g, device);
1553 char device[] = "/dev/VG/LV";
1554 char mountpoint[] = "/";
1557 r = guestfs_mount (g, device, mountpoint);
1562 char path[] = "/new";
1565 r = guestfs_cat (g, path);
1568 if (strcmp (r, expected) != 0) {
1569 fprintf (stderr, "test_lvresize_0: expected \"%s\" but got \"%s\"\n", expected, r);
1577 static int test_zerofree_0_skip (void)
1581 str = getenv ("SKIP_TEST_ZEROFREE_0");
1582 if (str && strcmp (str, "1") == 0) return 1;
1583 str = getenv ("SKIP_TEST_ZEROFREE");
1584 if (str && strcmp (str, "1") == 0) return 1;
1588 static int test_zerofree_0 (void)
1590 if (test_zerofree_0_skip ()) {
1591 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zerofree_0");
1595 /* InitNone|InitEmpty for test_zerofree_0 */
1597 char device[] = "/dev/sda";
1600 r = guestfs_blockdev_setrw (g, device);
1607 r = guestfs_umount_all (g);
1614 r = guestfs_lvm_remove_all (g);
1618 /* TestOutput for zerofree (0) */
1619 char expected[] = "test file";
1621 char device[] = "/dev/sda";
1622 char lines_0[] = ",";
1629 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1634 char fstype[] = "ext3";
1635 char device[] = "/dev/sda1";
1638 r = guestfs_mkfs (g, fstype, device);
1643 char device[] = "/dev/sda1";
1644 char mountpoint[] = "/";
1647 r = guestfs_mount (g, device, mountpoint);
1652 char path[] = "/new";
1653 char content[] = "test file";
1656 r = guestfs_write_file (g, path, content, 0);
1661 char pathordevice[] = "/dev/sda1";
1664 r = guestfs_umount (g, pathordevice);
1669 char device[] = "/dev/sda1";
1672 r = guestfs_zerofree (g, device);
1677 char device[] = "/dev/sda1";
1678 char mountpoint[] = "/";
1681 r = guestfs_mount (g, device, mountpoint);
1686 char path[] = "/new";
1689 r = guestfs_cat (g, path);
1692 if (strcmp (r, expected) != 0) {
1693 fprintf (stderr, "test_zerofree_0: expected \"%s\" but got \"%s\"\n", expected, r);
1701 static int test_hexdump_0_skip (void)
1705 str = getenv ("SKIP_TEST_HEXDUMP_0");
1706 if (str && strcmp (str, "1") == 0) return 1;
1707 str = getenv ("SKIP_TEST_HEXDUMP");
1708 if (str && strcmp (str, "1") == 0) return 1;
1712 static int test_hexdump_0 (void)
1714 if (test_hexdump_0_skip ()) {
1715 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_hexdump_0");
1719 /* InitBasicFS for test_hexdump_0: create ext2 on /dev/sda1 */
1721 char device[] = "/dev/sda";
1724 r = guestfs_blockdev_setrw (g, device);
1731 r = guestfs_umount_all (g);
1738 r = guestfs_lvm_remove_all (g);
1743 char device[] = "/dev/sda";
1744 char lines_0[] = ",";
1751 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1756 char fstype[] = "ext2";
1757 char device[] = "/dev/sda1";
1760 r = guestfs_mkfs (g, fstype, device);
1765 char device[] = "/dev/sda1";
1766 char mountpoint[] = "/";
1769 r = guestfs_mount (g, device, mountpoint);
1773 /* TestOutput for hexdump (0) */
1774 char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
1776 char path[] = "/new";
1777 char content[] = "hello\nworld\n";
1780 r = guestfs_write_file (g, path, content, 12);
1785 char path[] = "/new";
1788 r = guestfs_hexdump (g, path);
1791 if (strcmp (r, expected) != 0) {
1792 fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
1800 static int test_hexdump_1_skip (void)
1804 str = getenv ("SKIP_TEST_HEXDUMP_1");
1805 if (str && strcmp (str, "1") == 0) return 1;
1806 str = getenv ("SKIP_TEST_HEXDUMP");
1807 if (str && strcmp (str, "1") == 0) return 1;
1811 static int test_hexdump_1 (void)
1813 if (test_hexdump_1_skip ()) {
1814 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_hexdump_1");
1818 /* InitBasicFS for test_hexdump_1: create ext2 on /dev/sda1 */
1820 char device[] = "/dev/sda";
1823 r = guestfs_blockdev_setrw (g, device);
1830 r = guestfs_umount_all (g);
1837 r = guestfs_lvm_remove_all (g);
1842 char device[] = "/dev/sda";
1843 char lines_0[] = ",";
1850 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1855 char fstype[] = "ext2";
1856 char device[] = "/dev/sda1";
1859 r = guestfs_mkfs (g, fstype, device);
1864 char device[] = "/dev/sda1";
1865 char mountpoint[] = "/";
1868 r = guestfs_mount (g, device, mountpoint);
1872 /* TestRun for hexdump (1) */
1874 char options[] = "ro";
1875 char vfstype[] = "squashfs";
1876 char device[] = "/dev/sdd";
1877 char mountpoint[] = "/";
1880 r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
1885 char path[] = "/100krandom";
1888 r = guestfs_hexdump (g, path);
1896 static int test_strings_e_0_skip (void)
1900 str = getenv ("SKIP_TEST_STRINGS_E_0");
1901 if (str && strcmp (str, "1") == 0) return 1;
1902 str = getenv ("SKIP_TEST_STRINGS_E");
1903 if (str && strcmp (str, "1") == 0) return 1;
1907 static int test_strings_e_0 (void)
1909 if (test_strings_e_0_skip ()) {
1910 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_0");
1914 /* InitBasicFS for test_strings_e_0: create ext2 on /dev/sda1 */
1916 char device[] = "/dev/sda";
1919 r = guestfs_blockdev_setrw (g, device);
1926 r = guestfs_umount_all (g);
1933 r = guestfs_lvm_remove_all (g);
1938 char device[] = "/dev/sda";
1939 char lines_0[] = ",";
1946 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1951 char fstype[] = "ext2";
1952 char device[] = "/dev/sda1";
1955 r = guestfs_mkfs (g, fstype, device);
1960 char device[] = "/dev/sda1";
1961 char mountpoint[] = "/";
1964 r = guestfs_mount (g, device, mountpoint);
1968 /* TestOutputList for strings_e (0) */
1970 char path[] = "/new";
1971 char content[] = "hello\nworld\n";
1974 r = guestfs_write_file (g, path, content, 0);
1979 char encoding[] = "b";
1980 char path[] = "/new";
1984 r = guestfs_strings_e (g, encoding, path);
1988 fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
1992 for (i = 0; r[i] != NULL; ++i)
1999 static int test_strings_e_1_skip (void)
2003 str = getenv ("SKIP_TEST_STRINGS_E_1");
2004 if (str && strcmp (str, "1") == 0) return 1;
2005 str = getenv ("SKIP_TEST_STRINGS_E");
2006 if (str && strcmp (str, "1") == 0) return 1;
2010 static int test_strings_e_1 (void)
2012 if (test_strings_e_1_skip ()) {
2013 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_1");
2017 printf ("%s skipped (reason: test disabled in generator)\n", "test_strings_e_1");
2021 static int test_strings_0_skip (void)
2025 str = getenv ("SKIP_TEST_STRINGS_0");
2026 if (str && strcmp (str, "1") == 0) return 1;
2027 str = getenv ("SKIP_TEST_STRINGS");
2028 if (str && strcmp (str, "1") == 0) return 1;
2032 static int test_strings_0 (void)
2034 if (test_strings_0_skip ()) {
2035 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_0");
2039 /* InitBasicFS for test_strings_0: create ext2 on /dev/sda1 */
2041 char device[] = "/dev/sda";
2044 r = guestfs_blockdev_setrw (g, device);
2051 r = guestfs_umount_all (g);
2058 r = guestfs_lvm_remove_all (g);
2063 char device[] = "/dev/sda";
2064 char lines_0[] = ",";
2071 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2076 char fstype[] = "ext2";
2077 char device[] = "/dev/sda1";
2080 r = guestfs_mkfs (g, fstype, device);
2085 char device[] = "/dev/sda1";
2086 char mountpoint[] = "/";
2089 r = guestfs_mount (g, device, mountpoint);
2093 /* TestOutputList for strings (0) */
2095 char path[] = "/new";
2096 char content[] = "hello\nworld\n";
2099 r = guestfs_write_file (g, path, content, 0);
2104 char path[] = "/new";
2108 r = guestfs_strings (g, path);
2112 fprintf (stderr, "test_strings_0: short list returned from command\n");
2117 char expected[] = "hello";
2118 if (strcmp (r[0], expected) != 0) {
2119 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2124 fprintf (stderr, "test_strings_0: short list returned from command\n");
2129 char expected[] = "world";
2130 if (strcmp (r[1], expected) != 0) {
2131 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
2136 fprintf (stderr, "test_strings_0: extra elements returned from command\n");
2140 for (i = 0; r[i] != NULL; ++i)
2147 static int test_strings_1_skip (void)
2151 str = getenv ("SKIP_TEST_STRINGS_1");
2152 if (str && strcmp (str, "1") == 0) return 1;
2153 str = getenv ("SKIP_TEST_STRINGS");
2154 if (str && strcmp (str, "1") == 0) return 1;
2158 static int test_strings_1 (void)
2160 if (test_strings_1_skip ()) {
2161 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_1");
2165 /* InitBasicFS for test_strings_1: create ext2 on /dev/sda1 */
2167 char device[] = "/dev/sda";
2170 r = guestfs_blockdev_setrw (g, device);
2177 r = guestfs_umount_all (g);
2184 r = guestfs_lvm_remove_all (g);
2189 char device[] = "/dev/sda";
2190 char lines_0[] = ",";
2197 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2202 char fstype[] = "ext2";
2203 char device[] = "/dev/sda1";
2206 r = guestfs_mkfs (g, fstype, device);
2211 char device[] = "/dev/sda1";
2212 char mountpoint[] = "/";
2215 r = guestfs_mount (g, device, mountpoint);
2219 /* TestOutputList for strings (1) */
2221 char path[] = "/new";
2224 r = guestfs_touch (g, path);
2229 char path[] = "/new";
2233 r = guestfs_strings (g, path);
2237 fprintf (stderr, "test_strings_1: extra elements returned from command\n");
2241 for (i = 0; r[i] != NULL; ++i)
2248 static int test_equal_0_skip (void)
2252 str = getenv ("SKIP_TEST_EQUAL_0");
2253 if (str && strcmp (str, "1") == 0) return 1;
2254 str = getenv ("SKIP_TEST_EQUAL");
2255 if (str && strcmp (str, "1") == 0) return 1;
2259 static int test_equal_0 (void)
2261 if (test_equal_0_skip ()) {
2262 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_0");
2266 /* InitBasicFS for test_equal_0: create ext2 on /dev/sda1 */
2268 char device[] = "/dev/sda";
2271 r = guestfs_blockdev_setrw (g, device);
2278 r = guestfs_umount_all (g);
2285 r = guestfs_lvm_remove_all (g);
2290 char device[] = "/dev/sda";
2291 char lines_0[] = ",";
2298 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2303 char fstype[] = "ext2";
2304 char device[] = "/dev/sda1";
2307 r = guestfs_mkfs (g, fstype, device);
2312 char device[] = "/dev/sda1";
2313 char mountpoint[] = "/";
2316 r = guestfs_mount (g, device, mountpoint);
2320 /* TestOutputTrue for equal (0) */
2322 char path[] = "/file1";
2323 char content[] = "contents of a file";
2326 r = guestfs_write_file (g, path, content, 0);
2331 char src[] = "/file1";
2332 char dest[] = "/file2";
2335 r = guestfs_cp (g, src, dest);
2340 char file1[] = "/file1";
2341 char file2[] = "/file2";
2344 r = guestfs_equal (g, file1, file2);
2348 fprintf (stderr, "test_equal_0: expected true, got false\n");
2355 static int test_equal_1_skip (void)
2359 str = getenv ("SKIP_TEST_EQUAL_1");
2360 if (str && strcmp (str, "1") == 0) return 1;
2361 str = getenv ("SKIP_TEST_EQUAL");
2362 if (str && strcmp (str, "1") == 0) return 1;
2366 static int test_equal_1 (void)
2368 if (test_equal_1_skip ()) {
2369 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_1");
2373 /* InitBasicFS for test_equal_1: create ext2 on /dev/sda1 */
2375 char device[] = "/dev/sda";
2378 r = guestfs_blockdev_setrw (g, device);
2385 r = guestfs_umount_all (g);
2392 r = guestfs_lvm_remove_all (g);
2397 char device[] = "/dev/sda";
2398 char lines_0[] = ",";
2405 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2410 char fstype[] = "ext2";
2411 char device[] = "/dev/sda1";
2414 r = guestfs_mkfs (g, fstype, device);
2419 char device[] = "/dev/sda1";
2420 char mountpoint[] = "/";
2423 r = guestfs_mount (g, device, mountpoint);
2427 /* TestOutputFalse for equal (1) */
2429 char path[] = "/file1";
2430 char content[] = "contents of a file";
2433 r = guestfs_write_file (g, path, content, 0);
2438 char path[] = "/file2";
2439 char content[] = "contents of another file";
2442 r = guestfs_write_file (g, path, content, 0);
2447 char file1[] = "/file1";
2448 char file2[] = "/file2";
2451 r = guestfs_equal (g, file1, file2);
2455 fprintf (stderr, "test_equal_1: expected false, got true\n");
2462 static int test_equal_2_skip (void)
2466 str = getenv ("SKIP_TEST_EQUAL_2");
2467 if (str && strcmp (str, "1") == 0) return 1;
2468 str = getenv ("SKIP_TEST_EQUAL");
2469 if (str && strcmp (str, "1") == 0) return 1;
2473 static int test_equal_2 (void)
2475 if (test_equal_2_skip ()) {
2476 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_2");
2480 /* InitBasicFS for test_equal_2: create ext2 on /dev/sda1 */
2482 char device[] = "/dev/sda";
2485 r = guestfs_blockdev_setrw (g, device);
2492 r = guestfs_umount_all (g);
2499 r = guestfs_lvm_remove_all (g);
2504 char device[] = "/dev/sda";
2505 char lines_0[] = ",";
2512 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2517 char fstype[] = "ext2";
2518 char device[] = "/dev/sda1";
2521 r = guestfs_mkfs (g, fstype, device);
2526 char device[] = "/dev/sda1";
2527 char mountpoint[] = "/";
2530 r = guestfs_mount (g, device, mountpoint);
2534 /* TestLastFail for equal (2) */
2536 char file1[] = "/file1";
2537 char file2[] = "/file2";
2540 r = guestfs_equal (g, file1, file2);
2547 static int test_ping_daemon_0_skip (void)
2551 str = getenv ("SKIP_TEST_PING_DAEMON_0");
2552 if (str && strcmp (str, "1") == 0) return 1;
2553 str = getenv ("SKIP_TEST_PING_DAEMON");
2554 if (str && strcmp (str, "1") == 0) return 1;
2558 static int test_ping_daemon_0 (void)
2560 if (test_ping_daemon_0_skip ()) {
2561 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ping_daemon_0");
2565 /* InitNone|InitEmpty for test_ping_daemon_0 */
2567 char device[] = "/dev/sda";
2570 r = guestfs_blockdev_setrw (g, device);
2577 r = guestfs_umount_all (g);
2584 r = guestfs_lvm_remove_all (g);
2588 /* TestRun for ping_daemon (0) */
2592 r = guestfs_ping_daemon (g);
2599 static int test_dmesg_0_skip (void)
2603 str = getenv ("SKIP_TEST_DMESG_0");
2604 if (str && strcmp (str, "1") == 0) return 1;
2605 str = getenv ("SKIP_TEST_DMESG");
2606 if (str && strcmp (str, "1") == 0) return 1;
2610 static int test_dmesg_0 (void)
2612 if (test_dmesg_0_skip ()) {
2613 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_dmesg_0");
2617 /* InitNone|InitEmpty for test_dmesg_0 */
2619 char device[] = "/dev/sda";
2622 r = guestfs_blockdev_setrw (g, device);
2629 r = guestfs_umount_all (g);
2636 r = guestfs_lvm_remove_all (g);
2640 /* TestRun for dmesg (0) */
2644 r = guestfs_dmesg (g);
2652 static int test_drop_caches_0_skip (void)
2656 str = getenv ("SKIP_TEST_DROP_CACHES_0");
2657 if (str && strcmp (str, "1") == 0) return 1;
2658 str = getenv ("SKIP_TEST_DROP_CACHES");
2659 if (str && strcmp (str, "1") == 0) return 1;
2663 static int test_drop_caches_0 (void)
2665 if (test_drop_caches_0_skip ()) {
2666 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_drop_caches_0");
2670 /* InitNone|InitEmpty for test_drop_caches_0 */
2672 char device[] = "/dev/sda";
2675 r = guestfs_blockdev_setrw (g, device);
2682 r = guestfs_umount_all (g);
2689 r = guestfs_lvm_remove_all (g);
2693 /* TestRun for drop_caches (0) */
2697 r = guestfs_drop_caches (g, 3);
2704 static int test_mv_0_skip (void)
2708 str = getenv ("SKIP_TEST_MV_0");
2709 if (str && strcmp (str, "1") == 0) return 1;
2710 str = getenv ("SKIP_TEST_MV");
2711 if (str && strcmp (str, "1") == 0) return 1;
2715 static int test_mv_0 (void)
2717 if (test_mv_0_skip ()) {
2718 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_0");
2722 /* InitBasicFS for test_mv_0: create ext2 on /dev/sda1 */
2724 char device[] = "/dev/sda";
2727 r = guestfs_blockdev_setrw (g, device);
2734 r = guestfs_umount_all (g);
2741 r = guestfs_lvm_remove_all (g);
2746 char device[] = "/dev/sda";
2747 char lines_0[] = ",";
2754 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2759 char fstype[] = "ext2";
2760 char device[] = "/dev/sda1";
2763 r = guestfs_mkfs (g, fstype, device);
2768 char device[] = "/dev/sda1";
2769 char mountpoint[] = "/";
2772 r = guestfs_mount (g, device, mountpoint);
2776 /* TestOutput for mv (0) */
2777 char expected[] = "file content";
2779 char path[] = "/old";
2780 char content[] = "file content";
2783 r = guestfs_write_file (g, path, content, 0);
2788 char src[] = "/old";
2789 char dest[] = "/new";
2792 r = guestfs_mv (g, src, dest);
2797 char path[] = "/new";
2800 r = guestfs_cat (g, path);
2803 if (strcmp (r, expected) != 0) {
2804 fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
2812 static int test_mv_1_skip (void)
2816 str = getenv ("SKIP_TEST_MV_1");
2817 if (str && strcmp (str, "1") == 0) return 1;
2818 str = getenv ("SKIP_TEST_MV");
2819 if (str && strcmp (str, "1") == 0) return 1;
2823 static int test_mv_1 (void)
2825 if (test_mv_1_skip ()) {
2826 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_1");
2830 /* InitBasicFS for test_mv_1: create ext2 on /dev/sda1 */
2832 char device[] = "/dev/sda";
2835 r = guestfs_blockdev_setrw (g, device);
2842 r = guestfs_umount_all (g);
2849 r = guestfs_lvm_remove_all (g);
2854 char device[] = "/dev/sda";
2855 char lines_0[] = ",";
2862 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2867 char fstype[] = "ext2";
2868 char device[] = "/dev/sda1";
2871 r = guestfs_mkfs (g, fstype, device);
2876 char device[] = "/dev/sda1";
2877 char mountpoint[] = "/";
2880 r = guestfs_mount (g, device, mountpoint);
2884 /* TestOutputFalse for mv (1) */
2886 char path[] = "/old";
2887 char content[] = "file content";
2890 r = guestfs_write_file (g, path, content, 0);
2895 char src[] = "/old";
2896 char dest[] = "/new";
2899 r = guestfs_mv (g, src, dest);
2904 char path[] = "/old";
2907 r = guestfs_is_file (g, path);
2911 fprintf (stderr, "test_mv_1: expected false, got true\n");
2918 static int test_cp_a_0_skip (void)
2922 str = getenv ("SKIP_TEST_CP_A_0");
2923 if (str && strcmp (str, "1") == 0) return 1;
2924 str = getenv ("SKIP_TEST_CP_A");
2925 if (str && strcmp (str, "1") == 0) return 1;
2929 static int test_cp_a_0 (void)
2931 if (test_cp_a_0_skip ()) {
2932 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_a_0");
2936 /* InitBasicFS for test_cp_a_0: create ext2 on /dev/sda1 */
2938 char device[] = "/dev/sda";
2941 r = guestfs_blockdev_setrw (g, device);
2948 r = guestfs_umount_all (g);
2955 r = guestfs_lvm_remove_all (g);
2960 char device[] = "/dev/sda";
2961 char lines_0[] = ",";
2968 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2973 char fstype[] = "ext2";
2974 char device[] = "/dev/sda1";
2977 r = guestfs_mkfs (g, fstype, device);
2982 char device[] = "/dev/sda1";
2983 char mountpoint[] = "/";
2986 r = guestfs_mount (g, device, mountpoint);
2990 /* TestOutput for cp_a (0) */
2991 char expected[] = "file content";
2993 char path[] = "/olddir";
2996 r = guestfs_mkdir (g, path);
3001 char path[] = "/newdir";
3004 r = guestfs_mkdir (g, path);
3009 char path[] = "/olddir/file";
3010 char content[] = "file content";
3013 r = guestfs_write_file (g, path, content, 0);
3018 char src[] = "/olddir";
3019 char dest[] = "/newdir";
3022 r = guestfs_cp_a (g, src, dest);
3027 char path[] = "/newdir/olddir/file";
3030 r = guestfs_cat (g, path);
3033 if (strcmp (r, expected) != 0) {
3034 fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
3042 static int test_cp_0_skip (void)
3046 str = getenv ("SKIP_TEST_CP_0");
3047 if (str && strcmp (str, "1") == 0) return 1;
3048 str = getenv ("SKIP_TEST_CP");
3049 if (str && strcmp (str, "1") == 0) return 1;
3053 static int test_cp_0 (void)
3055 if (test_cp_0_skip ()) {
3056 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_0");
3060 /* InitBasicFS for test_cp_0: create ext2 on /dev/sda1 */
3062 char device[] = "/dev/sda";
3065 r = guestfs_blockdev_setrw (g, device);
3072 r = guestfs_umount_all (g);
3079 r = guestfs_lvm_remove_all (g);
3084 char device[] = "/dev/sda";
3085 char lines_0[] = ",";
3092 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3097 char fstype[] = "ext2";
3098 char device[] = "/dev/sda1";
3101 r = guestfs_mkfs (g, fstype, device);
3106 char device[] = "/dev/sda1";
3107 char mountpoint[] = "/";
3110 r = guestfs_mount (g, device, mountpoint);
3114 /* TestOutput for cp (0) */
3115 char expected[] = "file content";
3117 char path[] = "/old";
3118 char content[] = "file content";
3121 r = guestfs_write_file (g, path, content, 0);
3126 char src[] = "/old";
3127 char dest[] = "/new";
3130 r = guestfs_cp (g, src, dest);
3135 char path[] = "/new";
3138 r = guestfs_cat (g, path);
3141 if (strcmp (r, expected) != 0) {
3142 fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
3150 static int test_cp_1_skip (void)
3154 str = getenv ("SKIP_TEST_CP_1");
3155 if (str && strcmp (str, "1") == 0) return 1;
3156 str = getenv ("SKIP_TEST_CP");
3157 if (str && strcmp (str, "1") == 0) return 1;
3161 static int test_cp_1 (void)
3163 if (test_cp_1_skip ()) {
3164 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_1");
3168 /* InitBasicFS for test_cp_1: create ext2 on /dev/sda1 */
3170 char device[] = "/dev/sda";
3173 r = guestfs_blockdev_setrw (g, device);
3180 r = guestfs_umount_all (g);
3187 r = guestfs_lvm_remove_all (g);
3192 char device[] = "/dev/sda";
3193 char lines_0[] = ",";
3200 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3205 char fstype[] = "ext2";
3206 char device[] = "/dev/sda1";
3209 r = guestfs_mkfs (g, fstype, device);
3214 char device[] = "/dev/sda1";
3215 char mountpoint[] = "/";
3218 r = guestfs_mount (g, device, mountpoint);
3222 /* TestOutputTrue for cp (1) */
3224 char path[] = "/old";
3225 char content[] = "file content";
3228 r = guestfs_write_file (g, path, content, 0);
3233 char src[] = "/old";
3234 char dest[] = "/new";
3237 r = guestfs_cp (g, src, dest);
3242 char path[] = "/old";
3245 r = guestfs_is_file (g, path);
3249 fprintf (stderr, "test_cp_1: expected true, got false\n");
3256 static int test_cp_2_skip (void)
3260 str = getenv ("SKIP_TEST_CP_2");
3261 if (str && strcmp (str, "1") == 0) return 1;
3262 str = getenv ("SKIP_TEST_CP");
3263 if (str && strcmp (str, "1") == 0) return 1;
3267 static int test_cp_2 (void)
3269 if (test_cp_2_skip ()) {
3270 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_2");
3274 /* InitBasicFS for test_cp_2: create ext2 on /dev/sda1 */
3276 char device[] = "/dev/sda";
3279 r = guestfs_blockdev_setrw (g, device);
3286 r = guestfs_umount_all (g);
3293 r = guestfs_lvm_remove_all (g);
3298 char device[] = "/dev/sda";
3299 char lines_0[] = ",";
3306 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3311 char fstype[] = "ext2";
3312 char device[] = "/dev/sda1";
3315 r = guestfs_mkfs (g, fstype, device);
3320 char device[] = "/dev/sda1";
3321 char mountpoint[] = "/";
3324 r = guestfs_mount (g, device, mountpoint);
3328 /* TestOutput for cp (2) */
3329 char expected[] = "file content";
3331 char path[] = "/old";
3332 char content[] = "file content";
3335 r = guestfs_write_file (g, path, content, 0);
3340 char path[] = "/dir";
3343 r = guestfs_mkdir (g, path);
3348 char src[] = "/old";
3349 char dest[] = "/dir/new";
3352 r = guestfs_cp (g, src, dest);
3357 char path[] = "/dir/new";
3360 r = guestfs_cat (g, path);
3363 if (strcmp (r, expected) != 0) {
3364 fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
3372 static int test_grub_install_0_skip (void)
3376 str = getenv ("SKIP_TEST_GRUB_INSTALL_0");
3377 if (str && strcmp (str, "1") == 0) return 1;
3378 str = getenv ("SKIP_TEST_GRUB_INSTALL");
3379 if (str && strcmp (str, "1") == 0) return 1;
3383 static int test_grub_install_0 (void)
3385 if (test_grub_install_0_skip ()) {
3386 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_grub_install_0");
3390 /* InitBasicFS for test_grub_install_0: create ext2 on /dev/sda1 */
3392 char device[] = "/dev/sda";
3395 r = guestfs_blockdev_setrw (g, device);
3402 r = guestfs_umount_all (g);
3409 r = guestfs_lvm_remove_all (g);
3414 char device[] = "/dev/sda";
3415 char lines_0[] = ",";
3422 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3427 char fstype[] = "ext2";
3428 char device[] = "/dev/sda1";
3431 r = guestfs_mkfs (g, fstype, device);
3436 char device[] = "/dev/sda1";
3437 char mountpoint[] = "/";
3440 r = guestfs_mount (g, device, mountpoint);
3444 /* TestOutputTrue for grub_install (0) */
3447 char device[] = "/dev/sda1";
3450 r = guestfs_grub_install (g, root, device);
3455 char path[] = "/boot";
3458 r = guestfs_is_dir (g, path);
3462 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
3469 static int test_zero_0_skip (void)
3473 str = getenv ("SKIP_TEST_ZERO_0");
3474 if (str && strcmp (str, "1") == 0) return 1;
3475 str = getenv ("SKIP_TEST_ZERO");
3476 if (str && strcmp (str, "1") == 0) return 1;
3480 static int test_zero_0 (void)
3482 if (test_zero_0_skip ()) {
3483 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zero_0");
3487 /* InitBasicFS for test_zero_0: create ext2 on /dev/sda1 */
3489 char device[] = "/dev/sda";
3492 r = guestfs_blockdev_setrw (g, device);
3499 r = guestfs_umount_all (g);
3506 r = guestfs_lvm_remove_all (g);
3511 char device[] = "/dev/sda";
3512 char lines_0[] = ",";
3519 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3524 char fstype[] = "ext2";
3525 char device[] = "/dev/sda1";
3528 r = guestfs_mkfs (g, fstype, device);
3533 char device[] = "/dev/sda1";
3534 char mountpoint[] = "/";
3537 r = guestfs_mount (g, device, mountpoint);
3541 /* TestOutput for zero (0) */
3542 char expected[] = "data";
3544 char pathordevice[] = "/dev/sda1";
3547 r = guestfs_umount (g, pathordevice);
3552 char device[] = "/dev/sda1";
3555 r = guestfs_zero (g, device);
3560 char path[] = "/dev/sda1";
3563 r = guestfs_file (g, path);
3566 if (strcmp (r, expected) != 0) {
3567 fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
3575 static int test_fsck_0_skip (void)
3579 str = getenv ("SKIP_TEST_FSCK_0");
3580 if (str && strcmp (str, "1") == 0) return 1;
3581 str = getenv ("SKIP_TEST_FSCK");
3582 if (str && strcmp (str, "1") == 0) return 1;
3586 static int test_fsck_0 (void)
3588 if (test_fsck_0_skip ()) {
3589 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_0");
3593 /* InitBasicFS for test_fsck_0: create ext2 on /dev/sda1 */
3595 char device[] = "/dev/sda";
3598 r = guestfs_blockdev_setrw (g, device);
3605 r = guestfs_umount_all (g);
3612 r = guestfs_lvm_remove_all (g);
3617 char device[] = "/dev/sda";
3618 char lines_0[] = ",";
3625 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3630 char fstype[] = "ext2";
3631 char device[] = "/dev/sda1";
3634 r = guestfs_mkfs (g, fstype, device);
3639 char device[] = "/dev/sda1";
3640 char mountpoint[] = "/";
3643 r = guestfs_mount (g, device, mountpoint);
3647 /* TestOutputInt for fsck (0) */
3649 char pathordevice[] = "/dev/sda1";
3652 r = guestfs_umount (g, pathordevice);
3657 char fstype[] = "ext2";
3658 char device[] = "/dev/sda1";
3661 r = guestfs_fsck (g, fstype, device);
3665 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
3672 static int test_fsck_1_skip (void)
3676 str = getenv ("SKIP_TEST_FSCK_1");
3677 if (str && strcmp (str, "1") == 0) return 1;
3678 str = getenv ("SKIP_TEST_FSCK");
3679 if (str && strcmp (str, "1") == 0) return 1;
3683 static int test_fsck_1 (void)
3685 if (test_fsck_1_skip ()) {
3686 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_1");
3690 /* InitBasicFS for test_fsck_1: create ext2 on /dev/sda1 */
3692 char device[] = "/dev/sda";
3695 r = guestfs_blockdev_setrw (g, device);
3702 r = guestfs_umount_all (g);
3709 r = guestfs_lvm_remove_all (g);
3714 char device[] = "/dev/sda";
3715 char lines_0[] = ",";
3722 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3727 char fstype[] = "ext2";
3728 char device[] = "/dev/sda1";
3731 r = guestfs_mkfs (g, fstype, device);
3736 char device[] = "/dev/sda1";
3737 char mountpoint[] = "/";
3740 r = guestfs_mount (g, device, mountpoint);
3744 /* TestOutputInt for fsck (1) */
3746 char pathordevice[] = "/dev/sda1";
3749 r = guestfs_umount (g, pathordevice);
3754 char device[] = "/dev/sda1";
3757 r = guestfs_zero (g, device);
3762 char fstype[] = "ext2";
3763 char device[] = "/dev/sda1";
3766 r = guestfs_fsck (g, fstype, device);
3770 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
3777 static int test_set_e2uuid_0_skip (void)
3781 str = getenv ("SKIP_TEST_SET_E2UUID_0");
3782 if (str && strcmp (str, "1") == 0) return 1;
3783 str = getenv ("SKIP_TEST_SET_E2UUID");
3784 if (str && strcmp (str, "1") == 0) return 1;
3788 static int test_set_e2uuid_0 (void)
3790 if (test_set_e2uuid_0_skip ()) {
3791 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_0");
3795 /* InitBasicFS for test_set_e2uuid_0: create ext2 on /dev/sda1 */
3797 char device[] = "/dev/sda";
3800 r = guestfs_blockdev_setrw (g, device);
3807 r = guestfs_umount_all (g);
3814 r = guestfs_lvm_remove_all (g);
3819 char device[] = "/dev/sda";
3820 char lines_0[] = ",";
3827 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3832 char fstype[] = "ext2";
3833 char device[] = "/dev/sda1";
3836 r = guestfs_mkfs (g, fstype, device);
3841 char device[] = "/dev/sda1";
3842 char mountpoint[] = "/";
3845 r = guestfs_mount (g, device, mountpoint);
3849 /* TestOutput for set_e2uuid (0) */
3850 char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
3852 char device[] = "/dev/sda1";
3853 char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
3856 r = guestfs_set_e2uuid (g, device, uuid);
3861 char device[] = "/dev/sda1";
3864 r = guestfs_get_e2uuid (g, device);
3867 if (strcmp (r, expected) != 0) {
3868 fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
3876 static int test_set_e2uuid_1_skip (void)
3880 str = getenv ("SKIP_TEST_SET_E2UUID_1");
3881 if (str && strcmp (str, "1") == 0) return 1;
3882 str = getenv ("SKIP_TEST_SET_E2UUID");
3883 if (str && strcmp (str, "1") == 0) return 1;
3887 static int test_set_e2uuid_1 (void)
3889 if (test_set_e2uuid_1_skip ()) {
3890 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_1");
3894 /* InitBasicFS for test_set_e2uuid_1: create ext2 on /dev/sda1 */
3896 char device[] = "/dev/sda";
3899 r = guestfs_blockdev_setrw (g, device);
3906 r = guestfs_umount_all (g);
3913 r = guestfs_lvm_remove_all (g);
3918 char device[] = "/dev/sda";
3919 char lines_0[] = ",";
3926 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3931 char fstype[] = "ext2";
3932 char device[] = "/dev/sda1";
3935 r = guestfs_mkfs (g, fstype, device);
3940 char device[] = "/dev/sda1";
3941 char mountpoint[] = "/";
3944 r = guestfs_mount (g, device, mountpoint);
3948 /* TestOutput for set_e2uuid (1) */
3949 char expected[] = "";
3951 char device[] = "/dev/sda1";
3952 char uuid[] = "clear";
3955 r = guestfs_set_e2uuid (g, device, uuid);
3960 char device[] = "/dev/sda1";
3963 r = guestfs_get_e2uuid (g, device);
3966 if (strcmp (r, expected) != 0) {
3967 fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
3975 static int test_set_e2uuid_2_skip (void)
3979 str = getenv ("SKIP_TEST_SET_E2UUID_2");
3980 if (str && strcmp (str, "1") == 0) return 1;
3981 str = getenv ("SKIP_TEST_SET_E2UUID");
3982 if (str && strcmp (str, "1") == 0) return 1;
3986 static int test_set_e2uuid_2 (void)
3988 if (test_set_e2uuid_2_skip ()) {
3989 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_2");
3993 /* InitBasicFS for test_set_e2uuid_2: create ext2 on /dev/sda1 */
3995 char device[] = "/dev/sda";
3998 r = guestfs_blockdev_setrw (g, device);
4005 r = guestfs_umount_all (g);
4012 r = guestfs_lvm_remove_all (g);
4017 char device[] = "/dev/sda";
4018 char lines_0[] = ",";
4025 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4030 char fstype[] = "ext2";
4031 char device[] = "/dev/sda1";
4034 r = guestfs_mkfs (g, fstype, device);
4039 char device[] = "/dev/sda1";
4040 char mountpoint[] = "/";
4043 r = guestfs_mount (g, device, mountpoint);
4047 /* TestRun for set_e2uuid (2) */
4049 char device[] = "/dev/sda1";
4050 char uuid[] = "random";
4053 r = guestfs_set_e2uuid (g, device, uuid);
4060 static int test_set_e2uuid_3_skip (void)
4064 str = getenv ("SKIP_TEST_SET_E2UUID_3");
4065 if (str && strcmp (str, "1") == 0) return 1;
4066 str = getenv ("SKIP_TEST_SET_E2UUID");
4067 if (str && strcmp (str, "1") == 0) return 1;
4071 static int test_set_e2uuid_3 (void)
4073 if (test_set_e2uuid_3_skip ()) {
4074 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_3");
4078 /* InitBasicFS for test_set_e2uuid_3: create ext2 on /dev/sda1 */
4080 char device[] = "/dev/sda";
4083 r = guestfs_blockdev_setrw (g, device);
4090 r = guestfs_umount_all (g);
4097 r = guestfs_lvm_remove_all (g);
4102 char device[] = "/dev/sda";
4103 char lines_0[] = ",";
4110 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4115 char fstype[] = "ext2";
4116 char device[] = "/dev/sda1";
4119 r = guestfs_mkfs (g, fstype, device);
4124 char device[] = "/dev/sda1";
4125 char mountpoint[] = "/";
4128 r = guestfs_mount (g, device, mountpoint);
4132 /* TestRun for set_e2uuid (3) */
4134 char device[] = "/dev/sda1";
4135 char uuid[] = "time";
4138 r = guestfs_set_e2uuid (g, device, uuid);
4145 static int test_set_e2label_0_skip (void)
4149 str = getenv ("SKIP_TEST_SET_E2LABEL_0");
4150 if (str && strcmp (str, "1") == 0) return 1;
4151 str = getenv ("SKIP_TEST_SET_E2LABEL");
4152 if (str && strcmp (str, "1") == 0) return 1;
4156 static int test_set_e2label_0 (void)
4158 if (test_set_e2label_0_skip ()) {
4159 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2label_0");
4163 /* InitBasicFS for test_set_e2label_0: create ext2 on /dev/sda1 */
4165 char device[] = "/dev/sda";
4168 r = guestfs_blockdev_setrw (g, device);
4175 r = guestfs_umount_all (g);
4182 r = guestfs_lvm_remove_all (g);
4187 char device[] = "/dev/sda";
4188 char lines_0[] = ",";
4195 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4200 char fstype[] = "ext2";
4201 char device[] = "/dev/sda1";
4204 r = guestfs_mkfs (g, fstype, device);
4209 char device[] = "/dev/sda1";
4210 char mountpoint[] = "/";
4213 r = guestfs_mount (g, device, mountpoint);
4217 /* TestOutput for set_e2label (0) */
4218 char expected[] = "testlabel";
4220 char device[] = "/dev/sda1";
4221 char label[] = "testlabel";
4224 r = guestfs_set_e2label (g, device, label);
4229 char device[] = "/dev/sda1";
4232 r = guestfs_get_e2label (g, device);
4235 if (strcmp (r, expected) != 0) {
4236 fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
4244 static int test_pvremove_0_skip (void)
4248 str = getenv ("SKIP_TEST_PVREMOVE_0");
4249 if (str && strcmp (str, "1") == 0) return 1;
4250 str = getenv ("SKIP_TEST_PVREMOVE");
4251 if (str && strcmp (str, "1") == 0) return 1;
4255 static int test_pvremove_0 (void)
4257 if (test_pvremove_0_skip ()) {
4258 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_0");
4262 /* InitNone|InitEmpty for test_pvremove_0 */
4264 char device[] = "/dev/sda";
4267 r = guestfs_blockdev_setrw (g, device);
4274 r = guestfs_umount_all (g);
4281 r = guestfs_lvm_remove_all (g);
4285 /* TestOutputListOfDevices for pvremove (0) */
4287 char device[] = "/dev/sda";
4288 char lines_0[] = ",";
4295 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4300 char device[] = "/dev/sda1";
4303 r = guestfs_pvcreate (g, device);
4308 char volgroup[] = "VG";
4309 char physvols_0[] = "/dev/sda1";
4310 char *physvols[] = {
4316 r = guestfs_vgcreate (g, volgroup, physvols);
4321 char logvol[] = "LV1";
4322 char volgroup[] = "VG";
4325 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4330 char logvol[] = "LV2";
4331 char volgroup[] = "VG";
4334 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4339 char vgname[] = "VG";
4342 r = guestfs_vgremove (g, vgname);
4347 char device[] = "/dev/sda1";
4350 r = guestfs_pvremove (g, device);
4358 r = guestfs_lvs (g);
4362 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
4366 for (i = 0; r[i] != NULL; ++i)
4373 static int test_pvremove_1_skip (void)
4377 str = getenv ("SKIP_TEST_PVREMOVE_1");
4378 if (str && strcmp (str, "1") == 0) return 1;
4379 str = getenv ("SKIP_TEST_PVREMOVE");
4380 if (str && strcmp (str, "1") == 0) return 1;
4384 static int test_pvremove_1 (void)
4386 if (test_pvremove_1_skip ()) {
4387 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_1");
4391 /* InitNone|InitEmpty for test_pvremove_1 */
4393 char device[] = "/dev/sda";
4396 r = guestfs_blockdev_setrw (g, device);
4403 r = guestfs_umount_all (g);
4410 r = guestfs_lvm_remove_all (g);
4414 /* TestOutputListOfDevices for pvremove (1) */
4416 char device[] = "/dev/sda";
4417 char lines_0[] = ",";
4424 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4429 char device[] = "/dev/sda1";
4432 r = guestfs_pvcreate (g, device);
4437 char volgroup[] = "VG";
4438 char physvols_0[] = "/dev/sda1";
4439 char *physvols[] = {
4445 r = guestfs_vgcreate (g, volgroup, physvols);
4450 char logvol[] = "LV1";
4451 char volgroup[] = "VG";
4454 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4459 char logvol[] = "LV2";
4460 char volgroup[] = "VG";
4463 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4468 char vgname[] = "VG";
4471 r = guestfs_vgremove (g, vgname);
4476 char device[] = "/dev/sda1";
4479 r = guestfs_pvremove (g, device);
4487 r = guestfs_vgs (g);
4491 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
4495 for (i = 0; r[i] != NULL; ++i)
4502 static int test_pvremove_2_skip (void)
4506 str = getenv ("SKIP_TEST_PVREMOVE_2");
4507 if (str && strcmp (str, "1") == 0) return 1;
4508 str = getenv ("SKIP_TEST_PVREMOVE");
4509 if (str && strcmp (str, "1") == 0) return 1;
4513 static int test_pvremove_2 (void)
4515 if (test_pvremove_2_skip ()) {
4516 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_2");
4520 /* InitNone|InitEmpty for test_pvremove_2 */
4522 char device[] = "/dev/sda";
4525 r = guestfs_blockdev_setrw (g, device);
4532 r = guestfs_umount_all (g);
4539 r = guestfs_lvm_remove_all (g);
4543 /* TestOutputListOfDevices for pvremove (2) */
4545 char device[] = "/dev/sda";
4546 char lines_0[] = ",";
4553 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4558 char device[] = "/dev/sda1";
4561 r = guestfs_pvcreate (g, device);
4566 char volgroup[] = "VG";
4567 char physvols_0[] = "/dev/sda1";
4568 char *physvols[] = {
4574 r = guestfs_vgcreate (g, volgroup, physvols);
4579 char logvol[] = "LV1";
4580 char volgroup[] = "VG";
4583 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4588 char logvol[] = "LV2";
4589 char volgroup[] = "VG";
4592 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4597 char vgname[] = "VG";
4600 r = guestfs_vgremove (g, vgname);
4605 char device[] = "/dev/sda1";
4608 r = guestfs_pvremove (g, device);
4616 r = guestfs_pvs (g);
4620 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
4624 for (i = 0; r[i] != NULL; ++i)
4631 static int test_vgremove_0_skip (void)
4635 str = getenv ("SKIP_TEST_VGREMOVE_0");
4636 if (str && strcmp (str, "1") == 0) return 1;
4637 str = getenv ("SKIP_TEST_VGREMOVE");
4638 if (str && strcmp (str, "1") == 0) return 1;
4642 static int test_vgremove_0 (void)
4644 if (test_vgremove_0_skip ()) {
4645 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_0");
4649 /* InitNone|InitEmpty for test_vgremove_0 */
4651 char device[] = "/dev/sda";
4654 r = guestfs_blockdev_setrw (g, device);
4661 r = guestfs_umount_all (g);
4668 r = guestfs_lvm_remove_all (g);
4672 /* TestOutputList for vgremove (0) */
4674 char device[] = "/dev/sda";
4675 char lines_0[] = ",";
4682 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4687 char device[] = "/dev/sda1";
4690 r = guestfs_pvcreate (g, device);
4695 char volgroup[] = "VG";
4696 char physvols_0[] = "/dev/sda1";
4697 char *physvols[] = {
4703 r = guestfs_vgcreate (g, volgroup, physvols);
4708 char logvol[] = "LV1";
4709 char volgroup[] = "VG";
4712 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4717 char logvol[] = "LV2";
4718 char volgroup[] = "VG";
4721 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4726 char vgname[] = "VG";
4729 r = guestfs_vgremove (g, vgname);
4737 r = guestfs_lvs (g);
4741 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
4745 for (i = 0; r[i] != NULL; ++i)
4752 static int test_vgremove_1_skip (void)
4756 str = getenv ("SKIP_TEST_VGREMOVE_1");
4757 if (str && strcmp (str, "1") == 0) return 1;
4758 str = getenv ("SKIP_TEST_VGREMOVE");
4759 if (str && strcmp (str, "1") == 0) return 1;
4763 static int test_vgremove_1 (void)
4765 if (test_vgremove_1_skip ()) {
4766 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_1");
4770 /* InitNone|InitEmpty for test_vgremove_1 */
4772 char device[] = "/dev/sda";
4775 r = guestfs_blockdev_setrw (g, device);
4782 r = guestfs_umount_all (g);
4789 r = guestfs_lvm_remove_all (g);
4793 /* TestOutputList for vgremove (1) */
4795 char device[] = "/dev/sda";
4796 char lines_0[] = ",";
4803 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4808 char device[] = "/dev/sda1";
4811 r = guestfs_pvcreate (g, device);
4816 char volgroup[] = "VG";
4817 char physvols_0[] = "/dev/sda1";
4818 char *physvols[] = {
4824 r = guestfs_vgcreate (g, volgroup, physvols);
4829 char logvol[] = "LV1";
4830 char volgroup[] = "VG";
4833 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4838 char logvol[] = "LV2";
4839 char volgroup[] = "VG";
4842 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4847 char vgname[] = "VG";
4850 r = guestfs_vgremove (g, vgname);
4858 r = guestfs_vgs (g);
4862 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
4866 for (i = 0; r[i] != NULL; ++i)
4873 static int test_lvremove_0_skip (void)
4877 str = getenv ("SKIP_TEST_LVREMOVE_0");
4878 if (str && strcmp (str, "1") == 0) return 1;
4879 str = getenv ("SKIP_TEST_LVREMOVE");
4880 if (str && strcmp (str, "1") == 0) return 1;
4884 static int test_lvremove_0 (void)
4886 if (test_lvremove_0_skip ()) {
4887 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_0");
4891 /* InitNone|InitEmpty for test_lvremove_0 */
4893 char device[] = "/dev/sda";
4896 r = guestfs_blockdev_setrw (g, device);
4903 r = guestfs_umount_all (g);
4910 r = guestfs_lvm_remove_all (g);
4914 /* TestOutputList for lvremove (0) */
4916 char device[] = "/dev/sda";
4917 char lines_0[] = ",";
4924 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4929 char device[] = "/dev/sda1";
4932 r = guestfs_pvcreate (g, device);
4937 char volgroup[] = "VG";
4938 char physvols_0[] = "/dev/sda1";
4939 char *physvols[] = {
4945 r = guestfs_vgcreate (g, volgroup, physvols);
4950 char logvol[] = "LV1";
4951 char volgroup[] = "VG";
4954 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4959 char logvol[] = "LV2";
4960 char volgroup[] = "VG";
4963 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4968 char device[] = "/dev/VG/LV1";
4971 r = guestfs_lvremove (g, device);
4979 r = guestfs_lvs (g);
4983 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
4988 char expected[] = "/dev/VG/LV2";
4989 if (strcmp (r[0], expected) != 0) {
4990 fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
4995 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
4999 for (i = 0; r[i] != NULL; ++i)
5006 static int test_lvremove_1_skip (void)
5010 str = getenv ("SKIP_TEST_LVREMOVE_1");
5011 if (str && strcmp (str, "1") == 0) return 1;
5012 str = getenv ("SKIP_TEST_LVREMOVE");
5013 if (str && strcmp (str, "1") == 0) return 1;
5017 static int test_lvremove_1 (void)
5019 if (test_lvremove_1_skip ()) {
5020 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_1");
5024 /* InitNone|InitEmpty for test_lvremove_1 */
5026 char device[] = "/dev/sda";
5029 r = guestfs_blockdev_setrw (g, device);
5036 r = guestfs_umount_all (g);
5043 r = guestfs_lvm_remove_all (g);
5047 /* TestOutputList for lvremove (1) */
5049 char device[] = "/dev/sda";
5050 char lines_0[] = ",";
5057 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5062 char device[] = "/dev/sda1";
5065 r = guestfs_pvcreate (g, device);
5070 char volgroup[] = "VG";
5071 char physvols_0[] = "/dev/sda1";
5072 char *physvols[] = {
5078 r = guestfs_vgcreate (g, volgroup, physvols);
5083 char logvol[] = "LV1";
5084 char volgroup[] = "VG";
5087 r = guestfs_lvcreate (g, logvol, volgroup, 50);
5092 char logvol[] = "LV2";
5093 char volgroup[] = "VG";
5096 r = guestfs_lvcreate (g, logvol, volgroup, 50);
5101 char device[] = "/dev/VG";
5104 r = guestfs_lvremove (g, device);
5112 r = guestfs_lvs (g);
5116 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
5120 for (i = 0; r[i] != NULL; ++i)
5127 static int test_lvremove_2_skip (void)
5131 str = getenv ("SKIP_TEST_LVREMOVE_2");
5132 if (str && strcmp (str, "1") == 0) return 1;
5133 str = getenv ("SKIP_TEST_LVREMOVE");
5134 if (str && strcmp (str, "1") == 0) return 1;
5138 static int test_lvremove_2 (void)
5140 if (test_lvremove_2_skip ()) {
5141 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_2");
5145 /* InitNone|InitEmpty for test_lvremove_2 */
5147 char device[] = "/dev/sda";
5150 r = guestfs_blockdev_setrw (g, device);
5157 r = guestfs_umount_all (g);
5164 r = guestfs_lvm_remove_all (g);
5168 /* TestOutputList for lvremove (2) */
5170 char device[] = "/dev/sda";
5171 char lines_0[] = ",";
5178 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5183 char device[] = "/dev/sda1";
5186 r = guestfs_pvcreate (g, device);
5191 char volgroup[] = "VG";
5192 char physvols_0[] = "/dev/sda1";
5193 char *physvols[] = {
5199 r = guestfs_vgcreate (g, volgroup, physvols);
5204 char logvol[] = "LV1";
5205 char volgroup[] = "VG";
5208 r = guestfs_lvcreate (g, logvol, volgroup, 50);
5213 char logvol[] = "LV2";
5214 char volgroup[] = "VG";
5217 r = guestfs_lvcreate (g, logvol, volgroup, 50);
5222 char device[] = "/dev/VG";
5225 r = guestfs_lvremove (g, device);
5233 r = guestfs_vgs (g);
5237 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
5242 char expected[] = "VG";
5243 if (strcmp (r[0], expected) != 0) {
5244 fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5249 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
5253 for (i = 0; r[i] != NULL; ++i)
5260 static int test_mount_ro_0_skip (void)
5264 str = getenv ("SKIP_TEST_MOUNT_RO_0");
5265 if (str && strcmp (str, "1") == 0) return 1;
5266 str = getenv ("SKIP_TEST_MOUNT_RO");
5267 if (str && strcmp (str, "1") == 0) return 1;
5271 static int test_mount_ro_0 (void)
5273 if (test_mount_ro_0_skip ()) {
5274 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_0");
5278 /* InitBasicFS for test_mount_ro_0: create ext2 on /dev/sda1 */
5280 char device[] = "/dev/sda";
5283 r = guestfs_blockdev_setrw (g, device);
5290 r = guestfs_umount_all (g);
5297 r = guestfs_lvm_remove_all (g);
5302 char device[] = "/dev/sda";
5303 char lines_0[] = ",";
5310 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5315 char fstype[] = "ext2";
5316 char device[] = "/dev/sda1";
5319 r = guestfs_mkfs (g, fstype, device);
5324 char device[] = "/dev/sda1";
5325 char mountpoint[] = "/";
5328 r = guestfs_mount (g, device, mountpoint);
5332 /* TestLastFail for mount_ro (0) */
5334 char pathordevice[] = "/";
5337 r = guestfs_umount (g, pathordevice);
5342 char device[] = "/dev/sda1";
5343 char mountpoint[] = "/";
5346 r = guestfs_mount_ro (g, device, mountpoint);
5351 char path[] = "/new";
5354 r = guestfs_touch (g, path);
5361 static int test_mount_ro_1_skip (void)
5365 str = getenv ("SKIP_TEST_MOUNT_RO_1");
5366 if (str && strcmp (str, "1") == 0) return 1;
5367 str = getenv ("SKIP_TEST_MOUNT_RO");
5368 if (str && strcmp (str, "1") == 0) return 1;
5372 static int test_mount_ro_1 (void)
5374 if (test_mount_ro_1_skip ()) {
5375 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_1");
5379 /* InitBasicFS for test_mount_ro_1: create ext2 on /dev/sda1 */
5381 char device[] = "/dev/sda";
5384 r = guestfs_blockdev_setrw (g, device);
5391 r = guestfs_umount_all (g);
5398 r = guestfs_lvm_remove_all (g);
5403 char device[] = "/dev/sda";
5404 char lines_0[] = ",";
5411 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5416 char fstype[] = "ext2";
5417 char device[] = "/dev/sda1";
5420 r = guestfs_mkfs (g, fstype, device);
5425 char device[] = "/dev/sda1";
5426 char mountpoint[] = "/";
5429 r = guestfs_mount (g, device, mountpoint);
5433 /* TestOutput for mount_ro (1) */
5434 char expected[] = "data";
5436 char path[] = "/new";
5437 char content[] = "data";
5440 r = guestfs_write_file (g, path, content, 0);
5445 char pathordevice[] = "/";
5448 r = guestfs_umount (g, pathordevice);
5453 char device[] = "/dev/sda1";
5454 char mountpoint[] = "/";
5457 r = guestfs_mount_ro (g, device, mountpoint);
5462 char path[] = "/new";
5465 r = guestfs_cat (g, path);
5468 if (strcmp (r, expected) != 0) {
5469 fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
5477 static int test_tgz_in_0_skip (void)
5481 str = getenv ("SKIP_TEST_TGZ_IN_0");
5482 if (str && strcmp (str, "1") == 0) return 1;
5483 str = getenv ("SKIP_TEST_TGZ_IN");
5484 if (str && strcmp (str, "1") == 0) return 1;
5488 static int test_tgz_in_0 (void)
5490 if (test_tgz_in_0_skip ()) {
5491 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tgz_in_0");
5495 /* InitBasicFS for test_tgz_in_0: create ext2 on /dev/sda1 */
5497 char device[] = "/dev/sda";
5500 r = guestfs_blockdev_setrw (g, device);
5507 r = guestfs_umount_all (g);
5514 r = guestfs_lvm_remove_all (g);
5519 char device[] = "/dev/sda";
5520 char lines_0[] = ",";
5527 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5532 char fstype[] = "ext2";
5533 char device[] = "/dev/sda1";
5536 r = guestfs_mkfs (g, fstype, device);
5541 char device[] = "/dev/sda1";
5542 char mountpoint[] = "/";
5545 r = guestfs_mount (g, device, mountpoint);
5549 /* TestOutput for tgz_in (0) */
5550 char expected[] = "hello\n";
5552 char directory[] = "/";
5555 r = guestfs_tgz_in (g, "../images/helloworld.tar.gz", directory);
5560 char path[] = "/hello";
5563 r = guestfs_cat (g, path);
5566 if (strcmp (r, expected) != 0) {
5567 fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
5575 static int test_tar_in_0_skip (void)
5579 str = getenv ("SKIP_TEST_TAR_IN_0");
5580 if (str && strcmp (str, "1") == 0) return 1;
5581 str = getenv ("SKIP_TEST_TAR_IN");
5582 if (str && strcmp (str, "1") == 0) return 1;
5586 static int test_tar_in_0 (void)
5588 if (test_tar_in_0_skip ()) {
5589 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tar_in_0");
5593 /* InitBasicFS for test_tar_in_0: create ext2 on /dev/sda1 */
5595 char device[] = "/dev/sda";
5598 r = guestfs_blockdev_setrw (g, device);
5605 r = guestfs_umount_all (g);
5612 r = guestfs_lvm_remove_all (g);
5617 char device[] = "/dev/sda";
5618 char lines_0[] = ",";
5625 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5630 char fstype[] = "ext2";
5631 char device[] = "/dev/sda1";
5634 r = guestfs_mkfs (g, fstype, device);
5639 char device[] = "/dev/sda1";
5640 char mountpoint[] = "/";
5643 r = guestfs_mount (g, device, mountpoint);
5647 /* TestOutput for tar_in (0) */
5648 char expected[] = "hello\n";
5650 char directory[] = "/";
5653 r = guestfs_tar_in (g, "../images/helloworld.tar", directory);
5658 char path[] = "/hello";
5661 r = guestfs_cat (g, path);
5664 if (strcmp (r, expected) != 0) {
5665 fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
5673 static int test_checksum_0_skip (void)
5677 str = getenv ("SKIP_TEST_CHECKSUM_0");
5678 if (str && strcmp (str, "1") == 0) return 1;
5679 str = getenv ("SKIP_TEST_CHECKSUM");
5680 if (str && strcmp (str, "1") == 0) return 1;
5684 static int test_checksum_0 (void)
5686 if (test_checksum_0_skip ()) {
5687 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_0");
5691 /* InitBasicFS for test_checksum_0: create ext2 on /dev/sda1 */
5693 char device[] = "/dev/sda";
5696 r = guestfs_blockdev_setrw (g, device);
5703 r = guestfs_umount_all (g);
5710 r = guestfs_lvm_remove_all (g);
5715 char device[] = "/dev/sda";
5716 char lines_0[] = ",";
5723 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5728 char fstype[] = "ext2";
5729 char device[] = "/dev/sda1";
5732 r = guestfs_mkfs (g, fstype, device);
5737 char device[] = "/dev/sda1";
5738 char mountpoint[] = "/";
5741 r = guestfs_mount (g, device, mountpoint);
5745 /* TestOutput for checksum (0) */
5746 char expected[] = "935282863";
5748 char path[] = "/new";
5749 char content[] = "test\n";
5752 r = guestfs_write_file (g, path, content, 0);
5757 char csumtype[] = "crc";
5758 char path[] = "/new";
5761 r = guestfs_checksum (g, csumtype, path);
5764 if (strcmp (r, expected) != 0) {
5765 fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
5773 static int test_checksum_1_skip (void)
5777 str = getenv ("SKIP_TEST_CHECKSUM_1");
5778 if (str && strcmp (str, "1") == 0) return 1;
5779 str = getenv ("SKIP_TEST_CHECKSUM");
5780 if (str && strcmp (str, "1") == 0) return 1;
5784 static int test_checksum_1 (void)
5786 if (test_checksum_1_skip ()) {
5787 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_1");
5791 /* InitBasicFS for test_checksum_1: create ext2 on /dev/sda1 */
5793 char device[] = "/dev/sda";
5796 r = guestfs_blockdev_setrw (g, device);
5803 r = guestfs_umount_all (g);
5810 r = guestfs_lvm_remove_all (g);
5815 char device[] = "/dev/sda";
5816 char lines_0[] = ",";
5823 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5828 char fstype[] = "ext2";
5829 char device[] = "/dev/sda1";
5832 r = guestfs_mkfs (g, fstype, device);
5837 char device[] = "/dev/sda1";
5838 char mountpoint[] = "/";
5841 r = guestfs_mount (g, device, mountpoint);
5845 /* TestLastFail for checksum (1) */
5847 char csumtype[] = "crc";
5848 char path[] = "/new";
5851 r = guestfs_checksum (g, csumtype, path);
5859 static int test_checksum_2_skip (void)
5863 str = getenv ("SKIP_TEST_CHECKSUM_2");
5864 if (str && strcmp (str, "1") == 0) return 1;
5865 str = getenv ("SKIP_TEST_CHECKSUM");
5866 if (str && strcmp (str, "1") == 0) return 1;
5870 static int test_checksum_2 (void)
5872 if (test_checksum_2_skip ()) {
5873 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_2");
5877 /* InitBasicFS for test_checksum_2: create ext2 on /dev/sda1 */
5879 char device[] = "/dev/sda";
5882 r = guestfs_blockdev_setrw (g, device);
5889 r = guestfs_umount_all (g);
5896 r = guestfs_lvm_remove_all (g);
5901 char device[] = "/dev/sda";
5902 char lines_0[] = ",";
5909 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5914 char fstype[] = "ext2";
5915 char device[] = "/dev/sda1";
5918 r = guestfs_mkfs (g, fstype, device);
5923 char device[] = "/dev/sda1";
5924 char mountpoint[] = "/";
5927 r = guestfs_mount (g, device, mountpoint);
5931 /* TestOutput for checksum (2) */
5932 char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
5934 char path[] = "/new";
5935 char content[] = "test\n";
5938 r = guestfs_write_file (g, path, content, 0);
5943 char csumtype[] = "md5";
5944 char path[] = "/new";
5947 r = guestfs_checksum (g, csumtype, path);
5950 if (strcmp (r, expected) != 0) {
5951 fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
5959 static int test_checksum_3_skip (void)
5963 str = getenv ("SKIP_TEST_CHECKSUM_3");
5964 if (str && strcmp (str, "1") == 0) return 1;
5965 str = getenv ("SKIP_TEST_CHECKSUM");
5966 if (str && strcmp (str, "1") == 0) return 1;
5970 static int test_checksum_3 (void)
5972 if (test_checksum_3_skip ()) {
5973 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_3");
5977 /* InitBasicFS for test_checksum_3: create ext2 on /dev/sda1 */
5979 char device[] = "/dev/sda";
5982 r = guestfs_blockdev_setrw (g, device);
5989 r = guestfs_umount_all (g);
5996 r = guestfs_lvm_remove_all (g);
6001 char device[] = "/dev/sda";
6002 char lines_0[] = ",";
6009 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6014 char fstype[] = "ext2";
6015 char device[] = "/dev/sda1";
6018 r = guestfs_mkfs (g, fstype, device);
6023 char device[] = "/dev/sda1";
6024 char mountpoint[] = "/";
6027 r = guestfs_mount (g, device, mountpoint);
6031 /* TestOutput for checksum (3) */
6032 char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
6034 char path[] = "/new";
6035 char content[] = "test\n";
6038 r = guestfs_write_file (g, path, content, 0);
6043 char csumtype[] = "sha1";
6044 char path[] = "/new";
6047 r = guestfs_checksum (g, csumtype, path);
6050 if (strcmp (r, expected) != 0) {
6051 fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
6059 static int test_checksum_4_skip (void)
6063 str = getenv ("SKIP_TEST_CHECKSUM_4");
6064 if (str && strcmp (str, "1") == 0) return 1;
6065 str = getenv ("SKIP_TEST_CHECKSUM");
6066 if (str && strcmp (str, "1") == 0) return 1;
6070 static int test_checksum_4 (void)
6072 if (test_checksum_4_skip ()) {
6073 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_4");
6077 /* InitBasicFS for test_checksum_4: create ext2 on /dev/sda1 */
6079 char device[] = "/dev/sda";
6082 r = guestfs_blockdev_setrw (g, device);
6089 r = guestfs_umount_all (g);
6096 r = guestfs_lvm_remove_all (g);
6101 char device[] = "/dev/sda";
6102 char lines_0[] = ",";
6109 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6114 char fstype[] = "ext2";
6115 char device[] = "/dev/sda1";
6118 r = guestfs_mkfs (g, fstype, device);
6123 char device[] = "/dev/sda1";
6124 char mountpoint[] = "/";
6127 r = guestfs_mount (g, device, mountpoint);
6131 /* TestOutput for checksum (4) */
6132 char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
6134 char path[] = "/new";
6135 char content[] = "test\n";
6138 r = guestfs_write_file (g, path, content, 0);
6143 char csumtype[] = "sha224";
6144 char path[] = "/new";
6147 r = guestfs_checksum (g, csumtype, path);
6150 if (strcmp (r, expected) != 0) {
6151 fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
6159 static int test_checksum_5_skip (void)
6163 str = getenv ("SKIP_TEST_CHECKSUM_5");
6164 if (str && strcmp (str, "1") == 0) return 1;
6165 str = getenv ("SKIP_TEST_CHECKSUM");
6166 if (str && strcmp (str, "1") == 0) return 1;
6170 static int test_checksum_5 (void)
6172 if (test_checksum_5_skip ()) {
6173 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_5");
6177 /* InitBasicFS for test_checksum_5: create ext2 on /dev/sda1 */
6179 char device[] = "/dev/sda";
6182 r = guestfs_blockdev_setrw (g, device);
6189 r = guestfs_umount_all (g);
6196 r = guestfs_lvm_remove_all (g);
6201 char device[] = "/dev/sda";
6202 char lines_0[] = ",";
6209 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6214 char fstype[] = "ext2";
6215 char device[] = "/dev/sda1";
6218 r = guestfs_mkfs (g, fstype, device);
6223 char device[] = "/dev/sda1";
6224 char mountpoint[] = "/";
6227 r = guestfs_mount (g, device, mountpoint);
6231 /* TestOutput for checksum (5) */
6232 char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
6234 char path[] = "/new";
6235 char content[] = "test\n";
6238 r = guestfs_write_file (g, path, content, 0);
6243 char csumtype[] = "sha256";
6244 char path[] = "/new";
6247 r = guestfs_checksum (g, csumtype, path);
6250 if (strcmp (r, expected) != 0) {
6251 fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
6259 static int test_checksum_6_skip (void)
6263 str = getenv ("SKIP_TEST_CHECKSUM_6");
6264 if (str && strcmp (str, "1") == 0) return 1;
6265 str = getenv ("SKIP_TEST_CHECKSUM");
6266 if (str && strcmp (str, "1") == 0) return 1;
6270 static int test_checksum_6 (void)
6272 if (test_checksum_6_skip ()) {
6273 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_6");
6277 /* InitBasicFS for test_checksum_6: create ext2 on /dev/sda1 */
6279 char device[] = "/dev/sda";
6282 r = guestfs_blockdev_setrw (g, device);
6289 r = guestfs_umount_all (g);
6296 r = guestfs_lvm_remove_all (g);
6301 char device[] = "/dev/sda";
6302 char lines_0[] = ",";
6309 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6314 char fstype[] = "ext2";
6315 char device[] = "/dev/sda1";
6318 r = guestfs_mkfs (g, fstype, device);
6323 char device[] = "/dev/sda1";
6324 char mountpoint[] = "/";
6327 r = guestfs_mount (g, device, mountpoint);
6331 /* TestOutput for checksum (6) */
6332 char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
6334 char path[] = "/new";
6335 char content[] = "test\n";
6338 r = guestfs_write_file (g, path, content, 0);
6343 char csumtype[] = "sha384";
6344 char path[] = "/new";
6347 r = guestfs_checksum (g, csumtype, path);
6350 if (strcmp (r, expected) != 0) {
6351 fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
6359 static int test_checksum_7_skip (void)
6363 str = getenv ("SKIP_TEST_CHECKSUM_7");
6364 if (str && strcmp (str, "1") == 0) return 1;
6365 str = getenv ("SKIP_TEST_CHECKSUM");
6366 if (str && strcmp (str, "1") == 0) return 1;
6370 static int test_checksum_7 (void)
6372 if (test_checksum_7_skip ()) {
6373 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_7");
6377 /* InitBasicFS for test_checksum_7: create ext2 on /dev/sda1 */
6379 char device[] = "/dev/sda";
6382 r = guestfs_blockdev_setrw (g, device);
6389 r = guestfs_umount_all (g);
6396 r = guestfs_lvm_remove_all (g);
6401 char device[] = "/dev/sda";
6402 char lines_0[] = ",";
6409 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6414 char fstype[] = "ext2";
6415 char device[] = "/dev/sda1";
6418 r = guestfs_mkfs (g, fstype, device);
6423 char device[] = "/dev/sda1";
6424 char mountpoint[] = "/";
6427 r = guestfs_mount (g, device, mountpoint);
6431 /* TestOutput for checksum (7) */
6432 char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
6434 char path[] = "/new";
6435 char content[] = "test\n";
6438 r = guestfs_write_file (g, path, content, 0);
6443 char csumtype[] = "sha512";
6444 char path[] = "/new";
6447 r = guestfs_checksum (g, csumtype, path);
6450 if (strcmp (r, expected) != 0) {
6451 fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
6459 static int test_checksum_8_skip (void)
6463 str = getenv ("SKIP_TEST_CHECKSUM_8");
6464 if (str && strcmp (str, "1") == 0) return 1;
6465 str = getenv ("SKIP_TEST_CHECKSUM");
6466 if (str && strcmp (str, "1") == 0) return 1;
6470 static int test_checksum_8 (void)
6472 if (test_checksum_8_skip ()) {
6473 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_8");
6477 /* InitBasicFS for test_checksum_8: create ext2 on /dev/sda1 */
6479 char device[] = "/dev/sda";
6482 r = guestfs_blockdev_setrw (g, device);
6489 r = guestfs_umount_all (g);
6496 r = guestfs_lvm_remove_all (g);
6501 char device[] = "/dev/sda";
6502 char lines_0[] = ",";
6509 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6514 char fstype[] = "ext2";
6515 char device[] = "/dev/sda1";
6518 r = guestfs_mkfs (g, fstype, device);
6523 char device[] = "/dev/sda1";
6524 char mountpoint[] = "/";
6527 r = guestfs_mount (g, device, mountpoint);
6531 /* TestOutput for checksum (8) */
6532 char expected[] = "46d6ca27ee07cdc6fa99c2e138cc522c";
6534 char options[] = "ro";
6535 char vfstype[] = "squashfs";
6536 char device[] = "/dev/sdd";
6537 char mountpoint[] = "/";
6540 r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
6545 char csumtype[] = "md5";
6546 char path[] = "/known-3";
6549 r = guestfs_checksum (g, csumtype, path);
6552 if (strcmp (r, expected) != 0) {
6553 fprintf (stderr, "test_checksum_8: expected \"%s\" but got \"%s\"\n", expected, r);
6561 static int test_download_0_skip (void)
6565 str = getenv ("SKIP_TEST_DOWNLOAD_0");
6566 if (str && strcmp (str, "1") == 0) return 1;
6567 str = getenv ("SKIP_TEST_DOWNLOAD");
6568 if (str && strcmp (str, "1") == 0) return 1;
6572 static int test_download_0 (void)
6574 if (test_download_0_skip ()) {
6575 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_download_0");
6579 /* InitBasicFS for test_download_0: create ext2 on /dev/sda1 */
6581 char device[] = "/dev/sda";
6584 r = guestfs_blockdev_setrw (g, device);
6591 r = guestfs_umount_all (g);
6598 r = guestfs_lvm_remove_all (g);
6603 char device[] = "/dev/sda";
6604 char lines_0[] = ",";
6611 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6616 char fstype[] = "ext2";
6617 char device[] = "/dev/sda1";
6620 r = guestfs_mkfs (g, fstype, device);
6625 char device[] = "/dev/sda1";
6626 char mountpoint[] = "/";
6629 r = guestfs_mount (g, device, mountpoint);
6633 /* TestOutput for download (0) */
6634 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
6636 char remotefilename[] = "/COPYING.LIB";
6639 r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
6644 char remotefilename[] = "/COPYING.LIB";
6647 r = guestfs_download (g, remotefilename, "testdownload.tmp");
6652 char remotefilename[] = "/upload";
6655 r = guestfs_upload (g, "testdownload.tmp", remotefilename);
6660 char csumtype[] = "md5";
6661 char path[] = "/upload";
6664 r = guestfs_checksum (g, csumtype, path);
6667 if (strcmp (r, expected) != 0) {
6668 fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
6676 static int test_upload_0_skip (void)
6680 str = getenv ("SKIP_TEST_UPLOAD_0");
6681 if (str && strcmp (str, "1") == 0) return 1;
6682 str = getenv ("SKIP_TEST_UPLOAD");
6683 if (str && strcmp (str, "1") == 0) return 1;
6687 static int test_upload_0 (void)
6689 if (test_upload_0_skip ()) {
6690 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_upload_0");
6694 /* InitBasicFS for test_upload_0: create ext2 on /dev/sda1 */
6696 char device[] = "/dev/sda";
6699 r = guestfs_blockdev_setrw (g, device);
6706 r = guestfs_umount_all (g);
6713 r = guestfs_lvm_remove_all (g);
6718 char device[] = "/dev/sda";
6719 char lines_0[] = ",";
6726 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6731 char fstype[] = "ext2";
6732 char device[] = "/dev/sda1";
6735 r = guestfs_mkfs (g, fstype, device);
6740 char device[] = "/dev/sda1";
6741 char mountpoint[] = "/";
6744 r = guestfs_mount (g, device, mountpoint);
6748 /* TestOutput for upload (0) */
6749 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
6751 char remotefilename[] = "/COPYING.LIB";
6754 r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
6759 char csumtype[] = "md5";
6760 char path[] = "/COPYING.LIB";
6763 r = guestfs_checksum (g, csumtype, path);
6766 if (strcmp (r, expected) != 0) {
6767 fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
6775 static int test_blockdev_rereadpt_0_skip (void)
6779 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT_0");
6780 if (str && strcmp (str, "1") == 0) return 1;
6781 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT");
6782 if (str && strcmp (str, "1") == 0) return 1;
6786 static int test_blockdev_rereadpt_0 (void)
6788 if (test_blockdev_rereadpt_0_skip ()) {
6789 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_rereadpt_0");
6793 /* InitNone|InitEmpty for test_blockdev_rereadpt_0 */
6795 char device[] = "/dev/sda";
6798 r = guestfs_blockdev_setrw (g, device);
6805 r = guestfs_umount_all (g);
6812 r = guestfs_lvm_remove_all (g);
6816 /* TestRun for blockdev_rereadpt (0) */
6818 char device[] = "/dev/sda";
6821 r = guestfs_blockdev_rereadpt (g, device);
6828 static int test_blockdev_flushbufs_0_skip (void)
6832 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS_0");
6833 if (str && strcmp (str, "1") == 0) return 1;
6834 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS");
6835 if (str && strcmp (str, "1") == 0) return 1;
6839 static int test_blockdev_flushbufs_0 (void)
6841 if (test_blockdev_flushbufs_0_skip ()) {
6842 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_flushbufs_0");
6846 /* InitNone|InitEmpty for test_blockdev_flushbufs_0 */
6848 char device[] = "/dev/sda";
6851 r = guestfs_blockdev_setrw (g, device);
6858 r = guestfs_umount_all (g);
6865 r = guestfs_lvm_remove_all (g);
6869 /* TestRun for blockdev_flushbufs (0) */
6871 char device[] = "/dev/sda";
6874 r = guestfs_blockdev_flushbufs (g, device);
6881 static int test_blockdev_getsize64_0_skip (void)
6885 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64_0");
6886 if (str && strcmp (str, "1") == 0) return 1;
6887 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64");
6888 if (str && strcmp (str, "1") == 0) return 1;
6892 static int test_blockdev_getsize64_0 (void)
6894 if (test_blockdev_getsize64_0_skip ()) {
6895 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsize64_0");
6899 /* InitNone|InitEmpty for test_blockdev_getsize64_0 */
6901 char device[] = "/dev/sda";
6904 r = guestfs_blockdev_setrw (g, device);
6911 r = guestfs_umount_all (g);
6918 r = guestfs_lvm_remove_all (g);
6922 /* TestOutputInt for blockdev_getsize64 (0) */
6924 char device[] = "/dev/sda";
6927 r = guestfs_blockdev_getsize64 (g, device);
6930 if (r != 524288000) {
6931 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
6938 static int test_blockdev_getsz_0_skip (void)
6942 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ_0");
6943 if (str && strcmp (str, "1") == 0) return 1;
6944 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ");
6945 if (str && strcmp (str, "1") == 0) return 1;
6949 static int test_blockdev_getsz_0 (void)
6951 if (test_blockdev_getsz_0_skip ()) {
6952 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsz_0");
6956 /* InitNone|InitEmpty for test_blockdev_getsz_0 */
6958 char device[] = "/dev/sda";
6961 r = guestfs_blockdev_setrw (g, device);
6968 r = guestfs_umount_all (g);
6975 r = guestfs_lvm_remove_all (g);
6979 /* TestOutputInt for blockdev_getsz (0) */
6981 char device[] = "/dev/sda";
6984 r = guestfs_blockdev_getsz (g, device);
6988 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
6995 static int test_blockdev_getbsz_0_skip (void)
6999 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ_0");
7000 if (str && strcmp (str, "1") == 0) return 1;
7001 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ");
7002 if (str && strcmp (str, "1") == 0) return 1;
7006 static int test_blockdev_getbsz_0 (void)
7008 if (test_blockdev_getbsz_0_skip ()) {
7009 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getbsz_0");
7013 /* InitNone|InitEmpty for test_blockdev_getbsz_0 */
7015 char device[] = "/dev/sda";
7018 r = guestfs_blockdev_setrw (g, device);
7025 r = guestfs_umount_all (g);
7032 r = guestfs_lvm_remove_all (g);
7036 /* TestOutputInt for blockdev_getbsz (0) */
7038 char device[] = "/dev/sda";
7041 r = guestfs_blockdev_getbsz (g, device);
7045 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
7052 static int test_blockdev_getss_0_skip (void)
7056 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS_0");
7057 if (str && strcmp (str, "1") == 0) return 1;
7058 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS");
7059 if (str && strcmp (str, "1") == 0) return 1;
7063 static int test_blockdev_getss_0 (void)
7065 if (test_blockdev_getss_0_skip ()) {
7066 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getss_0");
7070 /* InitNone|InitEmpty for test_blockdev_getss_0 */
7072 char device[] = "/dev/sda";
7075 r = guestfs_blockdev_setrw (g, device);
7082 r = guestfs_umount_all (g);
7089 r = guestfs_lvm_remove_all (g);
7093 /* TestOutputInt for blockdev_getss (0) */
7095 char device[] = "/dev/sda";
7098 r = guestfs_blockdev_getss (g, device);
7102 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
7109 static int test_blockdev_getro_0_skip (void)
7113 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO_0");
7114 if (str && strcmp (str, "1") == 0) return 1;
7115 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO");
7116 if (str && strcmp (str, "1") == 0) return 1;
7120 static int test_blockdev_getro_0 (void)
7122 if (test_blockdev_getro_0_skip ()) {
7123 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getro_0");
7127 /* InitNone|InitEmpty for test_blockdev_getro_0 */
7129 char device[] = "/dev/sda";
7132 r = guestfs_blockdev_setrw (g, device);
7139 r = guestfs_umount_all (g);
7146 r = guestfs_lvm_remove_all (g);
7150 /* TestOutputTrue for blockdev_getro (0) */
7152 char device[] = "/dev/sda";
7155 r = guestfs_blockdev_setro (g, device);
7160 char device[] = "/dev/sda";
7163 r = guestfs_blockdev_getro (g, device);
7167 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
7174 static int test_blockdev_setrw_0_skip (void)
7178 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW_0");
7179 if (str && strcmp (str, "1") == 0) return 1;
7180 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW");
7181 if (str && strcmp (str, "1") == 0) return 1;
7185 static int test_blockdev_setrw_0 (void)
7187 if (test_blockdev_setrw_0_skip ()) {
7188 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setrw_0");
7192 /* InitNone|InitEmpty for test_blockdev_setrw_0 */
7194 char device[] = "/dev/sda";
7197 r = guestfs_blockdev_setrw (g, device);
7204 r = guestfs_umount_all (g);
7211 r = guestfs_lvm_remove_all (g);
7215 /* TestOutputFalse for blockdev_setrw (0) */
7217 char device[] = "/dev/sda";
7220 r = guestfs_blockdev_setrw (g, device);
7225 char device[] = "/dev/sda";
7228 r = guestfs_blockdev_getro (g, device);
7232 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
7239 static int test_blockdev_setro_0_skip (void)
7243 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO_0");
7244 if (str && strcmp (str, "1") == 0) return 1;
7245 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO");
7246 if (str && strcmp (str, "1") == 0) return 1;
7250 static int test_blockdev_setro_0 (void)
7252 if (test_blockdev_setro_0_skip ()) {
7253 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setro_0");
7257 /* InitNone|InitEmpty for test_blockdev_setro_0 */
7259 char device[] = "/dev/sda";
7262 r = guestfs_blockdev_setrw (g, device);
7269 r = guestfs_umount_all (g);
7276 r = guestfs_lvm_remove_all (g);
7280 /* TestOutputTrue for blockdev_setro (0) */
7282 char device[] = "/dev/sda";
7285 r = guestfs_blockdev_setro (g, device);
7290 char device[] = "/dev/sda";
7293 r = guestfs_blockdev_getro (g, device);
7297 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
7304 static int test_statvfs_0_skip (void)
7308 str = getenv ("SKIP_TEST_STATVFS_0");
7309 if (str && strcmp (str, "1") == 0) return 1;
7310 str = getenv ("SKIP_TEST_STATVFS");
7311 if (str && strcmp (str, "1") == 0) return 1;
7315 static int test_statvfs_0 (void)
7317 if (test_statvfs_0_skip ()) {
7318 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_statvfs_0");
7322 /* InitBasicFS for test_statvfs_0: create ext2 on /dev/sda1 */
7324 char device[] = "/dev/sda";
7327 r = guestfs_blockdev_setrw (g, device);
7334 r = guestfs_umount_all (g);
7341 r = guestfs_lvm_remove_all (g);
7346 char device[] = "/dev/sda";
7347 char lines_0[] = ",";
7354 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7359 char fstype[] = "ext2";
7360 char device[] = "/dev/sda1";
7363 r = guestfs_mkfs (g, fstype, device);
7368 char device[] = "/dev/sda1";
7369 char mountpoint[] = "/";
7372 r = guestfs_mount (g, device, mountpoint);
7376 /* TestOutputStruct for statvfs (0) */
7379 struct guestfs_statvfs *r;
7381 r = guestfs_statvfs (g, path);
7384 if (r->bfree != 487702) {
7385 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
7389 if (r->blocks != 490020) {
7390 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
7394 if (r->bsize != 1024) {
7395 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
7404 static int test_lstat_0_skip (void)
7408 str = getenv ("SKIP_TEST_LSTAT_0");
7409 if (str && strcmp (str, "1") == 0) return 1;
7410 str = getenv ("SKIP_TEST_LSTAT");
7411 if (str && strcmp (str, "1") == 0) return 1;
7415 static int test_lstat_0 (void)
7417 if (test_lstat_0_skip ()) {
7418 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lstat_0");
7422 /* InitBasicFS for test_lstat_0: create ext2 on /dev/sda1 */
7424 char device[] = "/dev/sda";
7427 r = guestfs_blockdev_setrw (g, device);
7434 r = guestfs_umount_all (g);
7441 r = guestfs_lvm_remove_all (g);
7446 char device[] = "/dev/sda";
7447 char lines_0[] = ",";
7454 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7459 char fstype[] = "ext2";
7460 char device[] = "/dev/sda1";
7463 r = guestfs_mkfs (g, fstype, device);
7468 char device[] = "/dev/sda1";
7469 char mountpoint[] = "/";
7472 r = guestfs_mount (g, device, mountpoint);
7476 /* TestOutputStruct for lstat (0) */
7478 char path[] = "/new";
7481 r = guestfs_touch (g, path);
7486 char path[] = "/new";
7487 struct guestfs_stat *r;
7489 r = guestfs_lstat (g, path);
7493 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
7502 static int test_stat_0_skip (void)
7506 str = getenv ("SKIP_TEST_STAT_0");
7507 if (str && strcmp (str, "1") == 0) return 1;
7508 str = getenv ("SKIP_TEST_STAT");
7509 if (str && strcmp (str, "1") == 0) return 1;
7513 static int test_stat_0 (void)
7515 if (test_stat_0_skip ()) {
7516 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_stat_0");
7520 /* InitBasicFS for test_stat_0: create ext2 on /dev/sda1 */
7522 char device[] = "/dev/sda";
7525 r = guestfs_blockdev_setrw (g, device);
7532 r = guestfs_umount_all (g);
7539 r = guestfs_lvm_remove_all (g);
7544 char device[] = "/dev/sda";
7545 char lines_0[] = ",";
7552 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7557 char fstype[] = "ext2";
7558 char device[] = "/dev/sda1";
7561 r = guestfs_mkfs (g, fstype, device);
7566 char device[] = "/dev/sda1";
7567 char mountpoint[] = "/";
7570 r = guestfs_mount (g, device, mountpoint);
7574 /* TestOutputStruct for stat (0) */
7576 char path[] = "/new";
7579 r = guestfs_touch (g, path);
7584 char path[] = "/new";
7585 struct guestfs_stat *r;
7587 r = guestfs_stat (g, path);
7591 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
7600 static int test_command_lines_0_skip (void)
7604 str = getenv ("SKIP_TEST_COMMAND_LINES_0");
7605 if (str && strcmp (str, "1") == 0) return 1;
7606 str = getenv ("SKIP_TEST_COMMAND_LINES");
7607 if (str && strcmp (str, "1") == 0) return 1;
7611 static int test_command_lines_0 (void)
7613 if (test_command_lines_0_skip ()) {
7614 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_0");
7618 /* InitBasicFS for test_command_lines_0: create ext2 on /dev/sda1 */
7620 char device[] = "/dev/sda";
7623 r = guestfs_blockdev_setrw (g, device);
7630 r = guestfs_umount_all (g);
7637 r = guestfs_lvm_remove_all (g);
7642 char device[] = "/dev/sda";
7643 char lines_0[] = ",";
7650 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7655 char fstype[] = "ext2";
7656 char device[] = "/dev/sda1";
7659 r = guestfs_mkfs (g, fstype, device);
7664 char device[] = "/dev/sda1";
7665 char mountpoint[] = "/";
7668 r = guestfs_mount (g, device, mountpoint);
7672 /* TestOutputList for command_lines (0) */
7674 char remotefilename[] = "/test-command";
7677 r = guestfs_upload (g, "test-command", remotefilename);
7682 char path[] = "/test-command";
7685 r = guestfs_chmod (g, 493, path);
7690 char arguments_0[] = "/test-command";
7691 char arguments_1[] = "1";
7692 char *arguments[] = {
7700 r = guestfs_command_lines (g, arguments);
7704 fprintf (stderr, "test_command_lines_0: short list returned from command\n");
7709 char expected[] = "Result1";
7710 if (strcmp (r[0], expected) != 0) {
7711 fprintf (stderr, "test_command_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7716 fprintf (stderr, "test_command_lines_0: extra elements returned from command\n");
7720 for (i = 0; r[i] != NULL; ++i)
7727 static int test_command_lines_1_skip (void)
7731 str = getenv ("SKIP_TEST_COMMAND_LINES_1");
7732 if (str && strcmp (str, "1") == 0) return 1;
7733 str = getenv ("SKIP_TEST_COMMAND_LINES");
7734 if (str && strcmp (str, "1") == 0) return 1;
7738 static int test_command_lines_1 (void)
7740 if (test_command_lines_1_skip ()) {
7741 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_1");
7745 /* InitBasicFS for test_command_lines_1: create ext2 on /dev/sda1 */
7747 char device[] = "/dev/sda";
7750 r = guestfs_blockdev_setrw (g, device);
7757 r = guestfs_umount_all (g);
7764 r = guestfs_lvm_remove_all (g);
7769 char device[] = "/dev/sda";
7770 char lines_0[] = ",";
7777 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7782 char fstype[] = "ext2";
7783 char device[] = "/dev/sda1";
7786 r = guestfs_mkfs (g, fstype, device);
7791 char device[] = "/dev/sda1";
7792 char mountpoint[] = "/";
7795 r = guestfs_mount (g, device, mountpoint);
7799 /* TestOutputList for command_lines (1) */
7801 char remotefilename[] = "/test-command";
7804 r = guestfs_upload (g, "test-command", remotefilename);
7809 char path[] = "/test-command";
7812 r = guestfs_chmod (g, 493, path);
7817 char arguments_0[] = "/test-command";
7818 char arguments_1[] = "2";
7819 char *arguments[] = {
7827 r = guestfs_command_lines (g, arguments);
7831 fprintf (stderr, "test_command_lines_1: short list returned from command\n");
7836 char expected[] = "Result2";
7837 if (strcmp (r[0], expected) != 0) {
7838 fprintf (stderr, "test_command_lines_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7843 fprintf (stderr, "test_command_lines_1: extra elements returned from command\n");
7847 for (i = 0; r[i] != NULL; ++i)
7854 static int test_command_lines_2_skip (void)
7858 str = getenv ("SKIP_TEST_COMMAND_LINES_2");
7859 if (str && strcmp (str, "1") == 0) return 1;
7860 str = getenv ("SKIP_TEST_COMMAND_LINES");
7861 if (str && strcmp (str, "1") == 0) return 1;
7865 static int test_command_lines_2 (void)
7867 if (test_command_lines_2_skip ()) {
7868 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_2");
7872 /* InitBasicFS for test_command_lines_2: create ext2 on /dev/sda1 */
7874 char device[] = "/dev/sda";
7877 r = guestfs_blockdev_setrw (g, device);
7884 r = guestfs_umount_all (g);
7891 r = guestfs_lvm_remove_all (g);
7896 char device[] = "/dev/sda";
7897 char lines_0[] = ",";
7904 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7909 char fstype[] = "ext2";
7910 char device[] = "/dev/sda1";
7913 r = guestfs_mkfs (g, fstype, device);
7918 char device[] = "/dev/sda1";
7919 char mountpoint[] = "/";
7922 r = guestfs_mount (g, device, mountpoint);
7926 /* TestOutputList for command_lines (2) */
7928 char remotefilename[] = "/test-command";
7931 r = guestfs_upload (g, "test-command", remotefilename);
7936 char path[] = "/test-command";
7939 r = guestfs_chmod (g, 493, path);
7944 char arguments_0[] = "/test-command";
7945 char arguments_1[] = "3";
7946 char *arguments[] = {
7954 r = guestfs_command_lines (g, arguments);
7958 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7963 char expected[] = "";
7964 if (strcmp (r[0], expected) != 0) {
7965 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7970 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7975 char expected[] = "Result3";
7976 if (strcmp (r[1], expected) != 0) {
7977 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7982 fprintf (stderr, "test_command_lines_2: extra elements returned from command\n");
7986 for (i = 0; r[i] != NULL; ++i)
7993 static int test_command_lines_3_skip (void)
7997 str = getenv ("SKIP_TEST_COMMAND_LINES_3");
7998 if (str && strcmp (str, "1") == 0) return 1;
7999 str = getenv ("SKIP_TEST_COMMAND_LINES");
8000 if (str && strcmp (str, "1") == 0) return 1;
8004 static int test_command_lines_3 (void)
8006 if (test_command_lines_3_skip ()) {
8007 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_3");
8011 /* InitBasicFS for test_command_lines_3: create ext2 on /dev/sda1 */
8013 char device[] = "/dev/sda";
8016 r = guestfs_blockdev_setrw (g, device);
8023 r = guestfs_umount_all (g);
8030 r = guestfs_lvm_remove_all (g);
8035 char device[] = "/dev/sda";
8036 char lines_0[] = ",";
8043 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8048 char fstype[] = "ext2";
8049 char device[] = "/dev/sda1";
8052 r = guestfs_mkfs (g, fstype, device);
8057 char device[] = "/dev/sda1";
8058 char mountpoint[] = "/";
8061 r = guestfs_mount (g, device, mountpoint);
8065 /* TestOutputList for command_lines (3) */
8067 char remotefilename[] = "/test-command";
8070 r = guestfs_upload (g, "test-command", remotefilename);
8075 char path[] = "/test-command";
8078 r = guestfs_chmod (g, 493, path);
8083 char arguments_0[] = "/test-command";
8084 char arguments_1[] = "4";
8085 char *arguments[] = {
8093 r = guestfs_command_lines (g, arguments);
8097 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
8102 char expected[] = "";
8103 if (strcmp (r[0], expected) != 0) {
8104 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8109 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
8114 char expected[] = "Result4";
8115 if (strcmp (r[1], expected) != 0) {
8116 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8121 fprintf (stderr, "test_command_lines_3: extra elements returned from command\n");
8125 for (i = 0; r[i] != NULL; ++i)
8132 static int test_command_lines_4_skip (void)
8136 str = getenv ("SKIP_TEST_COMMAND_LINES_4");
8137 if (str && strcmp (str, "1") == 0) return 1;
8138 str = getenv ("SKIP_TEST_COMMAND_LINES");
8139 if (str && strcmp (str, "1") == 0) return 1;
8143 static int test_command_lines_4 (void)
8145 if (test_command_lines_4_skip ()) {
8146 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_4");
8150 /* InitBasicFS for test_command_lines_4: create ext2 on /dev/sda1 */
8152 char device[] = "/dev/sda";
8155 r = guestfs_blockdev_setrw (g, device);
8162 r = guestfs_umount_all (g);
8169 r = guestfs_lvm_remove_all (g);
8174 char device[] = "/dev/sda";
8175 char lines_0[] = ",";
8182 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8187 char fstype[] = "ext2";
8188 char device[] = "/dev/sda1";
8191 r = guestfs_mkfs (g, fstype, device);
8196 char device[] = "/dev/sda1";
8197 char mountpoint[] = "/";
8200 r = guestfs_mount (g, device, mountpoint);
8204 /* TestOutputList for command_lines (4) */
8206 char remotefilename[] = "/test-command";
8209 r = guestfs_upload (g, "test-command", remotefilename);
8214 char path[] = "/test-command";
8217 r = guestfs_chmod (g, 493, path);
8222 char arguments_0[] = "/test-command";
8223 char arguments_1[] = "5";
8224 char *arguments[] = {
8232 r = guestfs_command_lines (g, arguments);
8236 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
8241 char expected[] = "";
8242 if (strcmp (r[0], expected) != 0) {
8243 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8248 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
8253 char expected[] = "Result5";
8254 if (strcmp (r[1], expected) != 0) {
8255 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8260 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
8265 char expected[] = "";
8266 if (strcmp (r[2], expected) != 0) {
8267 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8272 fprintf (stderr, "test_command_lines_4: extra elements returned from command\n");
8276 for (i = 0; r[i] != NULL; ++i)
8283 static int test_command_lines_5_skip (void)
8287 str = getenv ("SKIP_TEST_COMMAND_LINES_5");
8288 if (str && strcmp (str, "1") == 0) return 1;
8289 str = getenv ("SKIP_TEST_COMMAND_LINES");
8290 if (str && strcmp (str, "1") == 0) return 1;
8294 static int test_command_lines_5 (void)
8296 if (test_command_lines_5_skip ()) {
8297 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_5");
8301 /* InitBasicFS for test_command_lines_5: create ext2 on /dev/sda1 */
8303 char device[] = "/dev/sda";
8306 r = guestfs_blockdev_setrw (g, device);
8313 r = guestfs_umount_all (g);
8320 r = guestfs_lvm_remove_all (g);
8325 char device[] = "/dev/sda";
8326 char lines_0[] = ",";
8333 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8338 char fstype[] = "ext2";
8339 char device[] = "/dev/sda1";
8342 r = guestfs_mkfs (g, fstype, device);
8347 char device[] = "/dev/sda1";
8348 char mountpoint[] = "/";
8351 r = guestfs_mount (g, device, mountpoint);
8355 /* TestOutputList for command_lines (5) */
8357 char remotefilename[] = "/test-command";
8360 r = guestfs_upload (g, "test-command", remotefilename);
8365 char path[] = "/test-command";
8368 r = guestfs_chmod (g, 493, path);
8373 char arguments_0[] = "/test-command";
8374 char arguments_1[] = "6";
8375 char *arguments[] = {
8383 r = guestfs_command_lines (g, arguments);
8387 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
8392 char expected[] = "";
8393 if (strcmp (r[0], expected) != 0) {
8394 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8399 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
8404 char expected[] = "";
8405 if (strcmp (r[1], expected) != 0) {
8406 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8411 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
8416 char expected[] = "Result6";
8417 if (strcmp (r[2], expected) != 0) {
8418 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8423 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
8428 char expected[] = "";
8429 if (strcmp (r[3], expected) != 0) {
8430 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[3]);
8435 fprintf (stderr, "test_command_lines_5: extra elements returned from command\n");
8439 for (i = 0; r[i] != NULL; ++i)
8446 static int test_command_lines_6_skip (void)
8450 str = getenv ("SKIP_TEST_COMMAND_LINES_6");
8451 if (str && strcmp (str, "1") == 0) return 1;
8452 str = getenv ("SKIP_TEST_COMMAND_LINES");
8453 if (str && strcmp (str, "1") == 0) return 1;
8457 static int test_command_lines_6 (void)
8459 if (test_command_lines_6_skip ()) {
8460 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_6");
8464 /* InitBasicFS for test_command_lines_6: create ext2 on /dev/sda1 */
8466 char device[] = "/dev/sda";
8469 r = guestfs_blockdev_setrw (g, device);
8476 r = guestfs_umount_all (g);
8483 r = guestfs_lvm_remove_all (g);
8488 char device[] = "/dev/sda";
8489 char lines_0[] = ",";
8496 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8501 char fstype[] = "ext2";
8502 char device[] = "/dev/sda1";
8505 r = guestfs_mkfs (g, fstype, device);
8510 char device[] = "/dev/sda1";
8511 char mountpoint[] = "/";
8514 r = guestfs_mount (g, device, mountpoint);
8518 /* TestOutputList for command_lines (6) */
8520 char remotefilename[] = "/test-command";
8523 r = guestfs_upload (g, "test-command", remotefilename);
8528 char path[] = "/test-command";
8531 r = guestfs_chmod (g, 493, path);
8536 char arguments_0[] = "/test-command";
8537 char arguments_1[] = "7";
8538 char *arguments[] = {
8546 r = guestfs_command_lines (g, arguments);
8550 fprintf (stderr, "test_command_lines_6: extra elements returned from command\n");
8554 for (i = 0; r[i] != NULL; ++i)
8561 static int test_command_lines_7_skip (void)
8565 str = getenv ("SKIP_TEST_COMMAND_LINES_7");
8566 if (str && strcmp (str, "1") == 0) return 1;
8567 str = getenv ("SKIP_TEST_COMMAND_LINES");
8568 if (str && strcmp (str, "1") == 0) return 1;
8572 static int test_command_lines_7 (void)
8574 if (test_command_lines_7_skip ()) {
8575 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_7");
8579 /* InitBasicFS for test_command_lines_7: create ext2 on /dev/sda1 */
8581 char device[] = "/dev/sda";
8584 r = guestfs_blockdev_setrw (g, device);
8591 r = guestfs_umount_all (g);
8598 r = guestfs_lvm_remove_all (g);
8603 char device[] = "/dev/sda";
8604 char lines_0[] = ",";
8611 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8616 char fstype[] = "ext2";
8617 char device[] = "/dev/sda1";
8620 r = guestfs_mkfs (g, fstype, device);
8625 char device[] = "/dev/sda1";
8626 char mountpoint[] = "/";
8629 r = guestfs_mount (g, device, mountpoint);
8633 /* TestOutputList for command_lines (7) */
8635 char remotefilename[] = "/test-command";
8638 r = guestfs_upload (g, "test-command", remotefilename);
8643 char path[] = "/test-command";
8646 r = guestfs_chmod (g, 493, path);
8651 char arguments_0[] = "/test-command";
8652 char arguments_1[] = "8";
8653 char *arguments[] = {
8661 r = guestfs_command_lines (g, arguments);
8665 fprintf (stderr, "test_command_lines_7: short list returned from command\n");
8670 char expected[] = "";
8671 if (strcmp (r[0], expected) != 0) {
8672 fprintf (stderr, "test_command_lines_7: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8677 fprintf (stderr, "test_command_lines_7: extra elements returned from command\n");
8681 for (i = 0; r[i] != NULL; ++i)
8688 static int test_command_lines_8_skip (void)
8692 str = getenv ("SKIP_TEST_COMMAND_LINES_8");
8693 if (str && strcmp (str, "1") == 0) return 1;
8694 str = getenv ("SKIP_TEST_COMMAND_LINES");
8695 if (str && strcmp (str, "1") == 0) return 1;
8699 static int test_command_lines_8 (void)
8701 if (test_command_lines_8_skip ()) {
8702 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_8");
8706 /* InitBasicFS for test_command_lines_8: create ext2 on /dev/sda1 */
8708 char device[] = "/dev/sda";
8711 r = guestfs_blockdev_setrw (g, device);
8718 r = guestfs_umount_all (g);
8725 r = guestfs_lvm_remove_all (g);
8730 char device[] = "/dev/sda";
8731 char lines_0[] = ",";
8738 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8743 char fstype[] = "ext2";
8744 char device[] = "/dev/sda1";
8747 r = guestfs_mkfs (g, fstype, device);
8752 char device[] = "/dev/sda1";
8753 char mountpoint[] = "/";
8756 r = guestfs_mount (g, device, mountpoint);
8760 /* TestOutputList for command_lines (8) */
8762 char remotefilename[] = "/test-command";
8765 r = guestfs_upload (g, "test-command", remotefilename);
8770 char path[] = "/test-command";
8773 r = guestfs_chmod (g, 493, path);
8778 char arguments_0[] = "/test-command";
8779 char arguments_1[] = "9";
8780 char *arguments[] = {
8788 r = guestfs_command_lines (g, arguments);
8792 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8797 char expected[] = "";
8798 if (strcmp (r[0], expected) != 0) {
8799 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8804 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8809 char expected[] = "";
8810 if (strcmp (r[1], expected) != 0) {
8811 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8816 fprintf (stderr, "test_command_lines_8: extra elements returned from command\n");
8820 for (i = 0; r[i] != NULL; ++i)
8827 static int test_command_lines_9_skip (void)
8831 str = getenv ("SKIP_TEST_COMMAND_LINES_9");
8832 if (str && strcmp (str, "1") == 0) return 1;
8833 str = getenv ("SKIP_TEST_COMMAND_LINES");
8834 if (str && strcmp (str, "1") == 0) return 1;
8838 static int test_command_lines_9 (void)
8840 if (test_command_lines_9_skip ()) {
8841 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_9");
8845 /* InitBasicFS for test_command_lines_9: create ext2 on /dev/sda1 */
8847 char device[] = "/dev/sda";
8850 r = guestfs_blockdev_setrw (g, device);
8857 r = guestfs_umount_all (g);
8864 r = guestfs_lvm_remove_all (g);
8869 char device[] = "/dev/sda";
8870 char lines_0[] = ",";
8877 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8882 char fstype[] = "ext2";
8883 char device[] = "/dev/sda1";
8886 r = guestfs_mkfs (g, fstype, device);
8891 char device[] = "/dev/sda1";
8892 char mountpoint[] = "/";
8895 r = guestfs_mount (g, device, mountpoint);
8899 /* TestOutputList for command_lines (9) */
8901 char remotefilename[] = "/test-command";
8904 r = guestfs_upload (g, "test-command", remotefilename);
8909 char path[] = "/test-command";
8912 r = guestfs_chmod (g, 493, path);
8917 char arguments_0[] = "/test-command";
8918 char arguments_1[] = "10";
8919 char *arguments[] = {
8927 r = guestfs_command_lines (g, arguments);
8931 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8936 char expected[] = "Result10-1";
8937 if (strcmp (r[0], expected) != 0) {
8938 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8943 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8948 char expected[] = "Result10-2";
8949 if (strcmp (r[1], expected) != 0) {
8950 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8955 fprintf (stderr, "test_command_lines_9: extra elements returned from command\n");
8959 for (i = 0; r[i] != NULL; ++i)
8966 static int test_command_lines_10_skip (void)
8970 str = getenv ("SKIP_TEST_COMMAND_LINES_10");
8971 if (str && strcmp (str, "1") == 0) return 1;
8972 str = getenv ("SKIP_TEST_COMMAND_LINES");
8973 if (str && strcmp (str, "1") == 0) return 1;
8977 static int test_command_lines_10 (void)
8979 if (test_command_lines_10_skip ()) {
8980 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_10");
8984 /* InitBasicFS for test_command_lines_10: create ext2 on /dev/sda1 */
8986 char device[] = "/dev/sda";
8989 r = guestfs_blockdev_setrw (g, device);
8996 r = guestfs_umount_all (g);
9003 r = guestfs_lvm_remove_all (g);
9008 char device[] = "/dev/sda";
9009 char lines_0[] = ",";
9016 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9021 char fstype[] = "ext2";
9022 char device[] = "/dev/sda1";
9025 r = guestfs_mkfs (g, fstype, device);
9030 char device[] = "/dev/sda1";
9031 char mountpoint[] = "/";
9034 r = guestfs_mount (g, device, mountpoint);
9038 /* TestOutputList for command_lines (10) */
9040 char remotefilename[] = "/test-command";
9043 r = guestfs_upload (g, "test-command", remotefilename);
9048 char path[] = "/test-command";
9051 r = guestfs_chmod (g, 493, path);
9056 char arguments_0[] = "/test-command";
9057 char arguments_1[] = "11";
9058 char *arguments[] = {
9066 r = guestfs_command_lines (g, arguments);
9070 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
9075 char expected[] = "Result11-1";
9076 if (strcmp (r[0], expected) != 0) {
9077 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9082 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
9087 char expected[] = "Result11-2";
9088 if (strcmp (r[1], expected) != 0) {
9089 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9094 fprintf (stderr, "test_command_lines_10: extra elements returned from command\n");
9098 for (i = 0; r[i] != NULL; ++i)
9105 static int test_command_0_skip (void)
9109 str = getenv ("SKIP_TEST_COMMAND_0");
9110 if (str && strcmp (str, "1") == 0) return 1;
9111 str = getenv ("SKIP_TEST_COMMAND");
9112 if (str && strcmp (str, "1") == 0) return 1;
9116 static int test_command_0 (void)
9118 if (test_command_0_skip ()) {
9119 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_0");
9123 /* InitBasicFS for test_command_0: create ext2 on /dev/sda1 */
9125 char device[] = "/dev/sda";
9128 r = guestfs_blockdev_setrw (g, device);
9135 r = guestfs_umount_all (g);
9142 r = guestfs_lvm_remove_all (g);
9147 char device[] = "/dev/sda";
9148 char lines_0[] = ",";
9155 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9160 char fstype[] = "ext2";
9161 char device[] = "/dev/sda1";
9164 r = guestfs_mkfs (g, fstype, device);
9169 char device[] = "/dev/sda1";
9170 char mountpoint[] = "/";
9173 r = guestfs_mount (g, device, mountpoint);
9177 /* TestOutput for command (0) */
9178 char expected[] = "Result1";
9180 char remotefilename[] = "/test-command";
9183 r = guestfs_upload (g, "test-command", remotefilename);
9188 char path[] = "/test-command";
9191 r = guestfs_chmod (g, 493, path);
9196 char arguments_0[] = "/test-command";
9197 char arguments_1[] = "1";
9198 char *arguments[] = {
9205 r = guestfs_command (g, arguments);
9208 if (strcmp (r, expected) != 0) {
9209 fprintf (stderr, "test_command_0: expected \"%s\" but got \"%s\"\n", expected, r);
9217 static int test_command_1_skip (void)
9221 str = getenv ("SKIP_TEST_COMMAND_1");
9222 if (str && strcmp (str, "1") == 0) return 1;
9223 str = getenv ("SKIP_TEST_COMMAND");
9224 if (str && strcmp (str, "1") == 0) return 1;
9228 static int test_command_1 (void)
9230 if (test_command_1_skip ()) {
9231 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_1");
9235 /* InitBasicFS for test_command_1: create ext2 on /dev/sda1 */
9237 char device[] = "/dev/sda";
9240 r = guestfs_blockdev_setrw (g, device);
9247 r = guestfs_umount_all (g);
9254 r = guestfs_lvm_remove_all (g);
9259 char device[] = "/dev/sda";
9260 char lines_0[] = ",";
9267 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9272 char fstype[] = "ext2";
9273 char device[] = "/dev/sda1";
9276 r = guestfs_mkfs (g, fstype, device);
9281 char device[] = "/dev/sda1";
9282 char mountpoint[] = "/";
9285 r = guestfs_mount (g, device, mountpoint);
9289 /* TestOutput for command (1) */
9290 char expected[] = "Result2\n";
9292 char remotefilename[] = "/test-command";
9295 r = guestfs_upload (g, "test-command", remotefilename);
9300 char path[] = "/test-command";
9303 r = guestfs_chmod (g, 493, path);
9308 char arguments_0[] = "/test-command";
9309 char arguments_1[] = "2";
9310 char *arguments[] = {
9317 r = guestfs_command (g, arguments);
9320 if (strcmp (r, expected) != 0) {
9321 fprintf (stderr, "test_command_1: expected \"%s\" but got \"%s\"\n", expected, r);
9329 static int test_command_2_skip (void)
9333 str = getenv ("SKIP_TEST_COMMAND_2");
9334 if (str && strcmp (str, "1") == 0) return 1;
9335 str = getenv ("SKIP_TEST_COMMAND");
9336 if (str && strcmp (str, "1") == 0) return 1;
9340 static int test_command_2 (void)
9342 if (test_command_2_skip ()) {
9343 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_2");
9347 /* InitBasicFS for test_command_2: create ext2 on /dev/sda1 */
9349 char device[] = "/dev/sda";
9352 r = guestfs_blockdev_setrw (g, device);
9359 r = guestfs_umount_all (g);
9366 r = guestfs_lvm_remove_all (g);
9371 char device[] = "/dev/sda";
9372 char lines_0[] = ",";
9379 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9384 char fstype[] = "ext2";
9385 char device[] = "/dev/sda1";
9388 r = guestfs_mkfs (g, fstype, device);
9393 char device[] = "/dev/sda1";
9394 char mountpoint[] = "/";
9397 r = guestfs_mount (g, device, mountpoint);
9401 /* TestOutput for command (2) */
9402 char expected[] = "\nResult3";
9404 char remotefilename[] = "/test-command";
9407 r = guestfs_upload (g, "test-command", remotefilename);
9412 char path[] = "/test-command";
9415 r = guestfs_chmod (g, 493, path);
9420 char arguments_0[] = "/test-command";
9421 char arguments_1[] = "3";
9422 char *arguments[] = {
9429 r = guestfs_command (g, arguments);
9432 if (strcmp (r, expected) != 0) {
9433 fprintf (stderr, "test_command_2: expected \"%s\" but got \"%s\"\n", expected, r);
9441 static int test_command_3_skip (void)
9445 str = getenv ("SKIP_TEST_COMMAND_3");
9446 if (str && strcmp (str, "1") == 0) return 1;
9447 str = getenv ("SKIP_TEST_COMMAND");
9448 if (str && strcmp (str, "1") == 0) return 1;
9452 static int test_command_3 (void)
9454 if (test_command_3_skip ()) {
9455 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_3");
9459 /* InitBasicFS for test_command_3: create ext2 on /dev/sda1 */
9461 char device[] = "/dev/sda";
9464 r = guestfs_blockdev_setrw (g, device);
9471 r = guestfs_umount_all (g);
9478 r = guestfs_lvm_remove_all (g);
9483 char device[] = "/dev/sda";
9484 char lines_0[] = ",";
9491 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9496 char fstype[] = "ext2";
9497 char device[] = "/dev/sda1";
9500 r = guestfs_mkfs (g, fstype, device);
9505 char device[] = "/dev/sda1";
9506 char mountpoint[] = "/";
9509 r = guestfs_mount (g, device, mountpoint);
9513 /* TestOutput for command (3) */
9514 char expected[] = "\nResult4\n";
9516 char remotefilename[] = "/test-command";
9519 r = guestfs_upload (g, "test-command", remotefilename);
9524 char path[] = "/test-command";
9527 r = guestfs_chmod (g, 493, path);
9532 char arguments_0[] = "/test-command";
9533 char arguments_1[] = "4";
9534 char *arguments[] = {
9541 r = guestfs_command (g, arguments);
9544 if (strcmp (r, expected) != 0) {
9545 fprintf (stderr, "test_command_3: expected \"%s\" but got \"%s\"\n", expected, r);
9553 static int test_command_4_skip (void)
9557 str = getenv ("SKIP_TEST_COMMAND_4");
9558 if (str && strcmp (str, "1") == 0) return 1;
9559 str = getenv ("SKIP_TEST_COMMAND");
9560 if (str && strcmp (str, "1") == 0) return 1;
9564 static int test_command_4 (void)
9566 if (test_command_4_skip ()) {
9567 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_4");
9571 /* InitBasicFS for test_command_4: create ext2 on /dev/sda1 */
9573 char device[] = "/dev/sda";
9576 r = guestfs_blockdev_setrw (g, device);
9583 r = guestfs_umount_all (g);
9590 r = guestfs_lvm_remove_all (g);
9595 char device[] = "/dev/sda";
9596 char lines_0[] = ",";
9603 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9608 char fstype[] = "ext2";
9609 char device[] = "/dev/sda1";
9612 r = guestfs_mkfs (g, fstype, device);
9617 char device[] = "/dev/sda1";
9618 char mountpoint[] = "/";
9621 r = guestfs_mount (g, device, mountpoint);
9625 /* TestOutput for command (4) */
9626 char expected[] = "\nResult5\n\n";
9628 char remotefilename[] = "/test-command";
9631 r = guestfs_upload (g, "test-command", remotefilename);
9636 char path[] = "/test-command";
9639 r = guestfs_chmod (g, 493, path);
9644 char arguments_0[] = "/test-command";
9645 char arguments_1[] = "5";
9646 char *arguments[] = {
9653 r = guestfs_command (g, arguments);
9656 if (strcmp (r, expected) != 0) {
9657 fprintf (stderr, "test_command_4: expected \"%s\" but got \"%s\"\n", expected, r);
9665 static int test_command_5_skip (void)
9669 str = getenv ("SKIP_TEST_COMMAND_5");
9670 if (str && strcmp (str, "1") == 0) return 1;
9671 str = getenv ("SKIP_TEST_COMMAND");
9672 if (str && strcmp (str, "1") == 0) return 1;
9676 static int test_command_5 (void)
9678 if (test_command_5_skip ()) {
9679 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_5");
9683 /* InitBasicFS for test_command_5: create ext2 on /dev/sda1 */
9685 char device[] = "/dev/sda";
9688 r = guestfs_blockdev_setrw (g, device);
9695 r = guestfs_umount_all (g);
9702 r = guestfs_lvm_remove_all (g);
9707 char device[] = "/dev/sda";
9708 char lines_0[] = ",";
9715 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9720 char fstype[] = "ext2";
9721 char device[] = "/dev/sda1";
9724 r = guestfs_mkfs (g, fstype, device);
9729 char device[] = "/dev/sda1";
9730 char mountpoint[] = "/";
9733 r = guestfs_mount (g, device, mountpoint);
9737 /* TestOutput for command (5) */
9738 char expected[] = "\n\nResult6\n\n";
9740 char remotefilename[] = "/test-command";
9743 r = guestfs_upload (g, "test-command", remotefilename);
9748 char path[] = "/test-command";
9751 r = guestfs_chmod (g, 493, path);
9756 char arguments_0[] = "/test-command";
9757 char arguments_1[] = "6";
9758 char *arguments[] = {
9765 r = guestfs_command (g, arguments);
9768 if (strcmp (r, expected) != 0) {
9769 fprintf (stderr, "test_command_5: expected \"%s\" but got \"%s\"\n", expected, r);
9777 static int test_command_6_skip (void)
9781 str = getenv ("SKIP_TEST_COMMAND_6");
9782 if (str && strcmp (str, "1") == 0) return 1;
9783 str = getenv ("SKIP_TEST_COMMAND");
9784 if (str && strcmp (str, "1") == 0) return 1;
9788 static int test_command_6 (void)
9790 if (test_command_6_skip ()) {
9791 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_6");
9795 /* InitBasicFS for test_command_6: create ext2 on /dev/sda1 */
9797 char device[] = "/dev/sda";
9800 r = guestfs_blockdev_setrw (g, device);
9807 r = guestfs_umount_all (g);
9814 r = guestfs_lvm_remove_all (g);
9819 char device[] = "/dev/sda";
9820 char lines_0[] = ",";
9827 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9832 char fstype[] = "ext2";
9833 char device[] = "/dev/sda1";
9836 r = guestfs_mkfs (g, fstype, device);
9841 char device[] = "/dev/sda1";
9842 char mountpoint[] = "/";
9845 r = guestfs_mount (g, device, mountpoint);
9849 /* TestOutput for command (6) */
9850 char expected[] = "";
9852 char remotefilename[] = "/test-command";
9855 r = guestfs_upload (g, "test-command", remotefilename);
9860 char path[] = "/test-command";
9863 r = guestfs_chmod (g, 493, path);
9868 char arguments_0[] = "/test-command";
9869 char arguments_1[] = "7";
9870 char *arguments[] = {
9877 r = guestfs_command (g, arguments);
9880 if (strcmp (r, expected) != 0) {
9881 fprintf (stderr, "test_command_6: expected \"%s\" but got \"%s\"\n", expected, r);
9889 static int test_command_7_skip (void)
9893 str = getenv ("SKIP_TEST_COMMAND_7");
9894 if (str && strcmp (str, "1") == 0) return 1;
9895 str = getenv ("SKIP_TEST_COMMAND");
9896 if (str && strcmp (str, "1") == 0) return 1;
9900 static int test_command_7 (void)
9902 if (test_command_7_skip ()) {
9903 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_7");
9907 /* InitBasicFS for test_command_7: create ext2 on /dev/sda1 */
9909 char device[] = "/dev/sda";
9912 r = guestfs_blockdev_setrw (g, device);
9919 r = guestfs_umount_all (g);
9926 r = guestfs_lvm_remove_all (g);
9931 char device[] = "/dev/sda";
9932 char lines_0[] = ",";
9939 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9944 char fstype[] = "ext2";
9945 char device[] = "/dev/sda1";
9948 r = guestfs_mkfs (g, fstype, device);
9953 char device[] = "/dev/sda1";
9954 char mountpoint[] = "/";
9957 r = guestfs_mount (g, device, mountpoint);
9961 /* TestOutput for command (7) */
9962 char expected[] = "\n";
9964 char remotefilename[] = "/test-command";
9967 r = guestfs_upload (g, "test-command", remotefilename);
9972 char path[] = "/test-command";
9975 r = guestfs_chmod (g, 493, path);
9980 char arguments_0[] = "/test-command";
9981 char arguments_1[] = "8";
9982 char *arguments[] = {
9989 r = guestfs_command (g, arguments);
9992 if (strcmp (r, expected) != 0) {
9993 fprintf (stderr, "test_command_7: expected \"%s\" but got \"%s\"\n", expected, r);
10001 static int test_command_8_skip (void)
10005 str = getenv ("SKIP_TEST_COMMAND_8");
10006 if (str && strcmp (str, "1") == 0) return 1;
10007 str = getenv ("SKIP_TEST_COMMAND");
10008 if (str && strcmp (str, "1") == 0) return 1;
10012 static int test_command_8 (void)
10014 if (test_command_8_skip ()) {
10015 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_8");
10019 /* InitBasicFS for test_command_8: create ext2 on /dev/sda1 */
10021 char device[] = "/dev/sda";
10023 suppress_error = 0;
10024 r = guestfs_blockdev_setrw (g, device);
10030 suppress_error = 0;
10031 r = guestfs_umount_all (g);
10037 suppress_error = 0;
10038 r = guestfs_lvm_remove_all (g);
10043 char device[] = "/dev/sda";
10044 char lines_0[] = ",";
10050 suppress_error = 0;
10051 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10056 char fstype[] = "ext2";
10057 char device[] = "/dev/sda1";
10059 suppress_error = 0;
10060 r = guestfs_mkfs (g, fstype, device);
10065 char device[] = "/dev/sda1";
10066 char mountpoint[] = "/";
10068 suppress_error = 0;
10069 r = guestfs_mount (g, device, mountpoint);
10073 /* TestOutput for command (8) */
10074 char expected[] = "\n\n";
10076 char remotefilename[] = "/test-command";
10078 suppress_error = 0;
10079 r = guestfs_upload (g, "test-command", remotefilename);
10084 char path[] = "/test-command";
10086 suppress_error = 0;
10087 r = guestfs_chmod (g, 493, path);
10092 char arguments_0[] = "/test-command";
10093 char arguments_1[] = "9";
10094 char *arguments[] = {
10100 suppress_error = 0;
10101 r = guestfs_command (g, arguments);
10104 if (strcmp (r, expected) != 0) {
10105 fprintf (stderr, "test_command_8: expected \"%s\" but got \"%s\"\n", expected, r);
10113 static int test_command_9_skip (void)
10117 str = getenv ("SKIP_TEST_COMMAND_9");
10118 if (str && strcmp (str, "1") == 0) return 1;
10119 str = getenv ("SKIP_TEST_COMMAND");
10120 if (str && strcmp (str, "1") == 0) return 1;
10124 static int test_command_9 (void)
10126 if (test_command_9_skip ()) {
10127 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_9");
10131 /* InitBasicFS for test_command_9: create ext2 on /dev/sda1 */
10133 char device[] = "/dev/sda";
10135 suppress_error = 0;
10136 r = guestfs_blockdev_setrw (g, device);
10142 suppress_error = 0;
10143 r = guestfs_umount_all (g);
10149 suppress_error = 0;
10150 r = guestfs_lvm_remove_all (g);
10155 char device[] = "/dev/sda";
10156 char lines_0[] = ",";
10162 suppress_error = 0;
10163 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10168 char fstype[] = "ext2";
10169 char device[] = "/dev/sda1";
10171 suppress_error = 0;
10172 r = guestfs_mkfs (g, fstype, device);
10177 char device[] = "/dev/sda1";
10178 char mountpoint[] = "/";
10180 suppress_error = 0;
10181 r = guestfs_mount (g, device, mountpoint);
10185 /* TestOutput for command (9) */
10186 char expected[] = "Result10-1\nResult10-2\n";
10188 char remotefilename[] = "/test-command";
10190 suppress_error = 0;
10191 r = guestfs_upload (g, "test-command", remotefilename);
10196 char path[] = "/test-command";
10198 suppress_error = 0;
10199 r = guestfs_chmod (g, 493, path);
10204 char arguments_0[] = "/test-command";
10205 char arguments_1[] = "10";
10206 char *arguments[] = {
10212 suppress_error = 0;
10213 r = guestfs_command (g, arguments);
10216 if (strcmp (r, expected) != 0) {
10217 fprintf (stderr, "test_command_9: expected \"%s\" but got \"%s\"\n", expected, r);
10225 static int test_command_10_skip (void)
10229 str = getenv ("SKIP_TEST_COMMAND_10");
10230 if (str && strcmp (str, "1") == 0) return 1;
10231 str = getenv ("SKIP_TEST_COMMAND");
10232 if (str && strcmp (str, "1") == 0) return 1;
10236 static int test_command_10 (void)
10238 if (test_command_10_skip ()) {
10239 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_10");
10243 /* InitBasicFS for test_command_10: create ext2 on /dev/sda1 */
10245 char device[] = "/dev/sda";
10247 suppress_error = 0;
10248 r = guestfs_blockdev_setrw (g, device);
10254 suppress_error = 0;
10255 r = guestfs_umount_all (g);
10261 suppress_error = 0;
10262 r = guestfs_lvm_remove_all (g);
10267 char device[] = "/dev/sda";
10268 char lines_0[] = ",";
10274 suppress_error = 0;
10275 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10280 char fstype[] = "ext2";
10281 char device[] = "/dev/sda1";
10283 suppress_error = 0;
10284 r = guestfs_mkfs (g, fstype, device);
10289 char device[] = "/dev/sda1";
10290 char mountpoint[] = "/";
10292 suppress_error = 0;
10293 r = guestfs_mount (g, device, mountpoint);
10297 /* TestOutput for command (10) */
10298 char expected[] = "Result11-1\nResult11-2";
10300 char remotefilename[] = "/test-command";
10302 suppress_error = 0;
10303 r = guestfs_upload (g, "test-command", remotefilename);
10308 char path[] = "/test-command";
10310 suppress_error = 0;
10311 r = guestfs_chmod (g, 493, path);
10316 char arguments_0[] = "/test-command";
10317 char arguments_1[] = "11";
10318 char *arguments[] = {
10324 suppress_error = 0;
10325 r = guestfs_command (g, arguments);
10328 if (strcmp (r, expected) != 0) {
10329 fprintf (stderr, "test_command_10: expected \"%s\" but got \"%s\"\n", expected, r);
10337 static int test_command_11_skip (void)
10341 str = getenv ("SKIP_TEST_COMMAND_11");
10342 if (str && strcmp (str, "1") == 0) return 1;
10343 str = getenv ("SKIP_TEST_COMMAND");
10344 if (str && strcmp (str, "1") == 0) return 1;
10348 static int test_command_11 (void)
10350 if (test_command_11_skip ()) {
10351 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_11");
10355 /* InitBasicFS for test_command_11: create ext2 on /dev/sda1 */
10357 char device[] = "/dev/sda";
10359 suppress_error = 0;
10360 r = guestfs_blockdev_setrw (g, device);
10366 suppress_error = 0;
10367 r = guestfs_umount_all (g);
10373 suppress_error = 0;
10374 r = guestfs_lvm_remove_all (g);
10379 char device[] = "/dev/sda";
10380 char lines_0[] = ",";
10386 suppress_error = 0;
10387 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10392 char fstype[] = "ext2";
10393 char device[] = "/dev/sda1";
10395 suppress_error = 0;
10396 r = guestfs_mkfs (g, fstype, device);
10401 char device[] = "/dev/sda1";
10402 char mountpoint[] = "/";
10404 suppress_error = 0;
10405 r = guestfs_mount (g, device, mountpoint);
10409 /* TestLastFail for command (11) */
10411 char remotefilename[] = "/test-command";
10413 suppress_error = 0;
10414 r = guestfs_upload (g, "test-command", remotefilename);
10419 char path[] = "/test-command";
10421 suppress_error = 0;
10422 r = guestfs_chmod (g, 493, path);
10427 char arguments_0[] = "/test-command";
10428 char *arguments[] = {
10433 suppress_error = 1;
10434 r = guestfs_command (g, arguments);
10442 static int test_file_0_skip (void)
10446 str = getenv ("SKIP_TEST_FILE_0");
10447 if (str && strcmp (str, "1") == 0) return 1;
10448 str = getenv ("SKIP_TEST_FILE");
10449 if (str && strcmp (str, "1") == 0) return 1;
10453 static int test_file_0 (void)
10455 if (test_file_0_skip ()) {
10456 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_0");
10460 /* InitBasicFS for test_file_0: create ext2 on /dev/sda1 */
10462 char device[] = "/dev/sda";
10464 suppress_error = 0;
10465 r = guestfs_blockdev_setrw (g, device);
10471 suppress_error = 0;
10472 r = guestfs_umount_all (g);
10478 suppress_error = 0;
10479 r = guestfs_lvm_remove_all (g);
10484 char device[] = "/dev/sda";
10485 char lines_0[] = ",";
10491 suppress_error = 0;
10492 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10497 char fstype[] = "ext2";
10498 char device[] = "/dev/sda1";
10500 suppress_error = 0;
10501 r = guestfs_mkfs (g, fstype, device);
10506 char device[] = "/dev/sda1";
10507 char mountpoint[] = "/";
10509 suppress_error = 0;
10510 r = guestfs_mount (g, device, mountpoint);
10514 /* TestOutput for file (0) */
10515 char expected[] = "empty";
10517 char path[] = "/new";
10519 suppress_error = 0;
10520 r = guestfs_touch (g, path);
10525 char path[] = "/new";
10527 suppress_error = 0;
10528 r = guestfs_file (g, path);
10531 if (strcmp (r, expected) != 0) {
10532 fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
10540 static int test_file_1_skip (void)
10544 str = getenv ("SKIP_TEST_FILE_1");
10545 if (str && strcmp (str, "1") == 0) return 1;
10546 str = getenv ("SKIP_TEST_FILE");
10547 if (str && strcmp (str, "1") == 0) return 1;
10551 static int test_file_1 (void)
10553 if (test_file_1_skip ()) {
10554 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_1");
10558 /* InitBasicFS for test_file_1: create ext2 on /dev/sda1 */
10560 char device[] = "/dev/sda";
10562 suppress_error = 0;
10563 r = guestfs_blockdev_setrw (g, device);
10569 suppress_error = 0;
10570 r = guestfs_umount_all (g);
10576 suppress_error = 0;
10577 r = guestfs_lvm_remove_all (g);
10582 char device[] = "/dev/sda";
10583 char lines_0[] = ",";
10589 suppress_error = 0;
10590 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10595 char fstype[] = "ext2";
10596 char device[] = "/dev/sda1";
10598 suppress_error = 0;
10599 r = guestfs_mkfs (g, fstype, device);
10604 char device[] = "/dev/sda1";
10605 char mountpoint[] = "/";
10607 suppress_error = 0;
10608 r = guestfs_mount (g, device, mountpoint);
10612 /* TestOutput for file (1) */
10613 char expected[] = "ASCII text";
10615 char path[] = "/new";
10616 char content[] = "some content\n";
10618 suppress_error = 0;
10619 r = guestfs_write_file (g, path, content, 0);
10624 char path[] = "/new";
10626 suppress_error = 0;
10627 r = guestfs_file (g, path);
10630 if (strcmp (r, expected) != 0) {
10631 fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
10639 static int test_file_2_skip (void)
10643 str = getenv ("SKIP_TEST_FILE_2");
10644 if (str && strcmp (str, "1") == 0) return 1;
10645 str = getenv ("SKIP_TEST_FILE");
10646 if (str && strcmp (str, "1") == 0) return 1;
10650 static int test_file_2 (void)
10652 if (test_file_2_skip ()) {
10653 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_2");
10657 /* InitBasicFS for test_file_2: create ext2 on /dev/sda1 */
10659 char device[] = "/dev/sda";
10661 suppress_error = 0;
10662 r = guestfs_blockdev_setrw (g, device);
10668 suppress_error = 0;
10669 r = guestfs_umount_all (g);
10675 suppress_error = 0;
10676 r = guestfs_lvm_remove_all (g);
10681 char device[] = "/dev/sda";
10682 char lines_0[] = ",";
10688 suppress_error = 0;
10689 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10694 char fstype[] = "ext2";
10695 char device[] = "/dev/sda1";
10697 suppress_error = 0;
10698 r = guestfs_mkfs (g, fstype, device);
10703 char device[] = "/dev/sda1";
10704 char mountpoint[] = "/";
10706 suppress_error = 0;
10707 r = guestfs_mount (g, device, mountpoint);
10711 /* TestLastFail for file (2) */
10713 char path[] = "/nofile";
10715 suppress_error = 1;
10716 r = guestfs_file (g, path);
10724 static int test_umount_all_0_skip (void)
10728 str = getenv ("SKIP_TEST_UMOUNT_ALL_0");
10729 if (str && strcmp (str, "1") == 0) return 1;
10730 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10731 if (str && strcmp (str, "1") == 0) return 1;
10735 static int test_umount_all_0 (void)
10737 if (test_umount_all_0_skip ()) {
10738 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_0");
10742 /* InitBasicFS for test_umount_all_0: create ext2 on /dev/sda1 */
10744 char device[] = "/dev/sda";
10746 suppress_error = 0;
10747 r = guestfs_blockdev_setrw (g, device);
10753 suppress_error = 0;
10754 r = guestfs_umount_all (g);
10760 suppress_error = 0;
10761 r = guestfs_lvm_remove_all (g);
10766 char device[] = "/dev/sda";
10767 char lines_0[] = ",";
10773 suppress_error = 0;
10774 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10779 char fstype[] = "ext2";
10780 char device[] = "/dev/sda1";
10782 suppress_error = 0;
10783 r = guestfs_mkfs (g, fstype, device);
10788 char device[] = "/dev/sda1";
10789 char mountpoint[] = "/";
10791 suppress_error = 0;
10792 r = guestfs_mount (g, device, mountpoint);
10796 /* TestOutputList for umount_all (0) */
10799 suppress_error = 0;
10800 r = guestfs_umount_all (g);
10807 suppress_error = 0;
10808 r = guestfs_mounts (g);
10811 if (r[0] != NULL) {
10812 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
10816 for (i = 0; r[i] != NULL; ++i)
10823 static int test_umount_all_1_skip (void)
10827 str = getenv ("SKIP_TEST_UMOUNT_ALL_1");
10828 if (str && strcmp (str, "1") == 0) return 1;
10829 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10830 if (str && strcmp (str, "1") == 0) return 1;
10834 static int test_umount_all_1 (void)
10836 if (test_umount_all_1_skip ()) {
10837 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_1");
10841 /* InitNone|InitEmpty for test_umount_all_1 */
10843 char device[] = "/dev/sda";
10845 suppress_error = 0;
10846 r = guestfs_blockdev_setrw (g, device);
10852 suppress_error = 0;
10853 r = guestfs_umount_all (g);
10859 suppress_error = 0;
10860 r = guestfs_lvm_remove_all (g);
10864 /* TestOutputList for umount_all (1) */
10866 char device[] = "/dev/sda";
10867 char lines_0[] = ",10";
10868 char lines_1[] = ",20";
10869 char lines_2[] = ",";
10877 suppress_error = 0;
10878 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10883 char fstype[] = "ext2";
10884 char device[] = "/dev/sda1";
10886 suppress_error = 0;
10887 r = guestfs_mkfs (g, fstype, device);
10892 char fstype[] = "ext2";
10893 char device[] = "/dev/sda2";
10895 suppress_error = 0;
10896 r = guestfs_mkfs (g, fstype, device);
10901 char fstype[] = "ext2";
10902 char device[] = "/dev/sda3";
10904 suppress_error = 0;
10905 r = guestfs_mkfs (g, fstype, device);
10910 char device[] = "/dev/sda1";
10911 char mountpoint[] = "/";
10913 suppress_error = 0;
10914 r = guestfs_mount (g, device, mountpoint);
10919 char path[] = "/mp1";
10921 suppress_error = 0;
10922 r = guestfs_mkdir (g, path);
10927 char device[] = "/dev/sda2";
10928 char mountpoint[] = "/mp1";
10930 suppress_error = 0;
10931 r = guestfs_mount (g, device, mountpoint);
10936 char path[] = "/mp1/mp2";
10938 suppress_error = 0;
10939 r = guestfs_mkdir (g, path);
10944 char device[] = "/dev/sda3";
10945 char mountpoint[] = "/mp1/mp2";
10947 suppress_error = 0;
10948 r = guestfs_mount (g, device, mountpoint);
10953 char path[] = "/mp1/mp2/mp3";
10955 suppress_error = 0;
10956 r = guestfs_mkdir (g, path);
10962 suppress_error = 0;
10963 r = guestfs_umount_all (g);
10970 suppress_error = 0;
10971 r = guestfs_mounts (g);
10974 if (r[0] != NULL) {
10975 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
10979 for (i = 0; r[i] != NULL; ++i)
10986 static int test_mounts_0_skip (void)
10990 str = getenv ("SKIP_TEST_MOUNTS_0");
10991 if (str && strcmp (str, "1") == 0) return 1;
10992 str = getenv ("SKIP_TEST_MOUNTS");
10993 if (str && strcmp (str, "1") == 0) return 1;
10997 static int test_mounts_0 (void)
10999 if (test_mounts_0_skip ()) {
11000 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mounts_0");
11004 /* InitBasicFS for test_mounts_0: create ext2 on /dev/sda1 */
11006 char device[] = "/dev/sda";
11008 suppress_error = 0;
11009 r = guestfs_blockdev_setrw (g, device);
11015 suppress_error = 0;
11016 r = guestfs_umount_all (g);
11022 suppress_error = 0;
11023 r = guestfs_lvm_remove_all (g);
11028 char device[] = "/dev/sda";
11029 char lines_0[] = ",";
11035 suppress_error = 0;
11036 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11041 char fstype[] = "ext2";
11042 char device[] = "/dev/sda1";
11044 suppress_error = 0;
11045 r = guestfs_mkfs (g, fstype, device);
11050 char device[] = "/dev/sda1";
11051 char mountpoint[] = "/";
11053 suppress_error = 0;
11054 r = guestfs_mount (g, device, mountpoint);
11058 /* TestOutputListOfDevices for mounts (0) */
11062 suppress_error = 0;
11063 r = guestfs_mounts (g);
11067 fprintf (stderr, "test_mounts_0: short list returned from command\n");
11072 char expected[] = "/dev/sda1";
11074 if (strcmp (r[0], expected) != 0) {
11075 fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11079 if (r[1] != NULL) {
11080 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
11084 for (i = 0; r[i] != NULL; ++i)
11091 static int test_umount_0_skip (void)
11095 str = getenv ("SKIP_TEST_UMOUNT_0");
11096 if (str && strcmp (str, "1") == 0) return 1;
11097 str = getenv ("SKIP_TEST_UMOUNT");
11098 if (str && strcmp (str, "1") == 0) return 1;
11102 static int test_umount_0 (void)
11104 if (test_umount_0_skip ()) {
11105 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_0");
11109 /* InitNone|InitEmpty for test_umount_0 */
11111 char device[] = "/dev/sda";
11113 suppress_error = 0;
11114 r = guestfs_blockdev_setrw (g, device);
11120 suppress_error = 0;
11121 r = guestfs_umount_all (g);
11127 suppress_error = 0;
11128 r = guestfs_lvm_remove_all (g);
11132 /* TestOutputListOfDevices for umount (0) */
11134 char device[] = "/dev/sda";
11135 char lines_0[] = ",";
11141 suppress_error = 0;
11142 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11147 char fstype[] = "ext2";
11148 char device[] = "/dev/sda1";
11150 suppress_error = 0;
11151 r = guestfs_mkfs (g, fstype, device);
11156 char device[] = "/dev/sda1";
11157 char mountpoint[] = "/";
11159 suppress_error = 0;
11160 r = guestfs_mount (g, device, mountpoint);
11167 suppress_error = 0;
11168 r = guestfs_mounts (g);
11172 fprintf (stderr, "test_umount_0: short list returned from command\n");
11177 char expected[] = "/dev/sda1";
11179 if (strcmp (r[0], expected) != 0) {
11180 fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11184 if (r[1] != NULL) {
11185 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
11189 for (i = 0; r[i] != NULL; ++i)
11196 static int test_umount_1_skip (void)
11200 str = getenv ("SKIP_TEST_UMOUNT_1");
11201 if (str && strcmp (str, "1") == 0) return 1;
11202 str = getenv ("SKIP_TEST_UMOUNT");
11203 if (str && strcmp (str, "1") == 0) return 1;
11207 static int test_umount_1 (void)
11209 if (test_umount_1_skip ()) {
11210 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_1");
11214 /* InitNone|InitEmpty for test_umount_1 */
11216 char device[] = "/dev/sda";
11218 suppress_error = 0;
11219 r = guestfs_blockdev_setrw (g, device);
11225 suppress_error = 0;
11226 r = guestfs_umount_all (g);
11232 suppress_error = 0;
11233 r = guestfs_lvm_remove_all (g);
11237 /* TestOutputList for umount (1) */
11239 char device[] = "/dev/sda";
11240 char lines_0[] = ",";
11246 suppress_error = 0;
11247 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11252 char fstype[] = "ext2";
11253 char device[] = "/dev/sda1";
11255 suppress_error = 0;
11256 r = guestfs_mkfs (g, fstype, device);
11261 char device[] = "/dev/sda1";
11262 char mountpoint[] = "/";
11264 suppress_error = 0;
11265 r = guestfs_mount (g, device, mountpoint);
11270 char pathordevice[] = "/";
11272 suppress_error = 0;
11273 r = guestfs_umount (g, pathordevice);
11280 suppress_error = 0;
11281 r = guestfs_mounts (g);
11284 if (r[0] != NULL) {
11285 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
11289 for (i = 0; r[i] != NULL; ++i)
11296 static int test_write_file_0_skip (void)
11300 str = getenv ("SKIP_TEST_WRITE_FILE_0");
11301 if (str && strcmp (str, "1") == 0) return 1;
11302 str = getenv ("SKIP_TEST_WRITE_FILE");
11303 if (str && strcmp (str, "1") == 0) return 1;
11307 static int test_write_file_0 (void)
11309 if (test_write_file_0_skip ()) {
11310 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_0");
11314 /* InitBasicFS for test_write_file_0: create ext2 on /dev/sda1 */
11316 char device[] = "/dev/sda";
11318 suppress_error = 0;
11319 r = guestfs_blockdev_setrw (g, device);
11325 suppress_error = 0;
11326 r = guestfs_umount_all (g);
11332 suppress_error = 0;
11333 r = guestfs_lvm_remove_all (g);
11338 char device[] = "/dev/sda";
11339 char lines_0[] = ",";
11345 suppress_error = 0;
11346 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11351 char fstype[] = "ext2";
11352 char device[] = "/dev/sda1";
11354 suppress_error = 0;
11355 r = guestfs_mkfs (g, fstype, device);
11360 char device[] = "/dev/sda1";
11361 char mountpoint[] = "/";
11363 suppress_error = 0;
11364 r = guestfs_mount (g, device, mountpoint);
11368 /* TestOutput for write_file (0) */
11369 char expected[] = "new file contents";
11371 char path[] = "/new";
11372 char content[] = "new file contents";
11374 suppress_error = 0;
11375 r = guestfs_write_file (g, path, content, 0);
11380 char path[] = "/new";
11382 suppress_error = 0;
11383 r = guestfs_cat (g, path);
11386 if (strcmp (r, expected) != 0) {
11387 fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
11395 static int test_write_file_1_skip (void)
11399 str = getenv ("SKIP_TEST_WRITE_FILE_1");
11400 if (str && strcmp (str, "1") == 0) return 1;
11401 str = getenv ("SKIP_TEST_WRITE_FILE");
11402 if (str && strcmp (str, "1") == 0) return 1;
11406 static int test_write_file_1 (void)
11408 if (test_write_file_1_skip ()) {
11409 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_1");
11413 /* InitBasicFS for test_write_file_1: create ext2 on /dev/sda1 */
11415 char device[] = "/dev/sda";
11417 suppress_error = 0;
11418 r = guestfs_blockdev_setrw (g, device);
11424 suppress_error = 0;
11425 r = guestfs_umount_all (g);
11431 suppress_error = 0;
11432 r = guestfs_lvm_remove_all (g);
11437 char device[] = "/dev/sda";
11438 char lines_0[] = ",";
11444 suppress_error = 0;
11445 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11450 char fstype[] = "ext2";
11451 char device[] = "/dev/sda1";
11453 suppress_error = 0;
11454 r = guestfs_mkfs (g, fstype, device);
11459 char device[] = "/dev/sda1";
11460 char mountpoint[] = "/";
11462 suppress_error = 0;
11463 r = guestfs_mount (g, device, mountpoint);
11467 /* TestOutput for write_file (1) */
11468 char expected[] = "\nnew file contents\n";
11470 char path[] = "/new";
11471 char content[] = "\nnew file contents\n";
11473 suppress_error = 0;
11474 r = guestfs_write_file (g, path, content, 0);
11479 char path[] = "/new";
11481 suppress_error = 0;
11482 r = guestfs_cat (g, path);
11485 if (strcmp (r, expected) != 0) {
11486 fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
11494 static int test_write_file_2_skip (void)
11498 str = getenv ("SKIP_TEST_WRITE_FILE_2");
11499 if (str && strcmp (str, "1") == 0) return 1;
11500 str = getenv ("SKIP_TEST_WRITE_FILE");
11501 if (str && strcmp (str, "1") == 0) return 1;
11505 static int test_write_file_2 (void)
11507 if (test_write_file_2_skip ()) {
11508 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_2");
11512 /* InitBasicFS for test_write_file_2: create ext2 on /dev/sda1 */
11514 char device[] = "/dev/sda";
11516 suppress_error = 0;
11517 r = guestfs_blockdev_setrw (g, device);
11523 suppress_error = 0;
11524 r = guestfs_umount_all (g);
11530 suppress_error = 0;
11531 r = guestfs_lvm_remove_all (g);
11536 char device[] = "/dev/sda";
11537 char lines_0[] = ",";
11543 suppress_error = 0;
11544 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11549 char fstype[] = "ext2";
11550 char device[] = "/dev/sda1";
11552 suppress_error = 0;
11553 r = guestfs_mkfs (g, fstype, device);
11558 char device[] = "/dev/sda1";
11559 char mountpoint[] = "/";
11561 suppress_error = 0;
11562 r = guestfs_mount (g, device, mountpoint);
11566 /* TestOutput for write_file (2) */
11567 char expected[] = "\n\n";
11569 char path[] = "/new";
11570 char content[] = "\n\n";
11572 suppress_error = 0;
11573 r = guestfs_write_file (g, path, content, 0);
11578 char path[] = "/new";
11580 suppress_error = 0;
11581 r = guestfs_cat (g, path);
11584 if (strcmp (r, expected) != 0) {
11585 fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
11593 static int test_write_file_3_skip (void)
11597 str = getenv ("SKIP_TEST_WRITE_FILE_3");
11598 if (str && strcmp (str, "1") == 0) return 1;
11599 str = getenv ("SKIP_TEST_WRITE_FILE");
11600 if (str && strcmp (str, "1") == 0) return 1;
11604 static int test_write_file_3 (void)
11606 if (test_write_file_3_skip ()) {
11607 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_3");
11611 /* InitBasicFS for test_write_file_3: create ext2 on /dev/sda1 */
11613 char device[] = "/dev/sda";
11615 suppress_error = 0;
11616 r = guestfs_blockdev_setrw (g, device);
11622 suppress_error = 0;
11623 r = guestfs_umount_all (g);
11629 suppress_error = 0;
11630 r = guestfs_lvm_remove_all (g);
11635 char device[] = "/dev/sda";
11636 char lines_0[] = ",";
11642 suppress_error = 0;
11643 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11648 char fstype[] = "ext2";
11649 char device[] = "/dev/sda1";
11651 suppress_error = 0;
11652 r = guestfs_mkfs (g, fstype, device);
11657 char device[] = "/dev/sda1";
11658 char mountpoint[] = "/";
11660 suppress_error = 0;
11661 r = guestfs_mount (g, device, mountpoint);
11665 /* TestOutput for write_file (3) */
11666 char expected[] = "";
11668 char path[] = "/new";
11669 char content[] = "";
11671 suppress_error = 0;
11672 r = guestfs_write_file (g, path, content, 0);
11677 char path[] = "/new";
11679 suppress_error = 0;
11680 r = guestfs_cat (g, path);
11683 if (strcmp (r, expected) != 0) {
11684 fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
11692 static int test_write_file_4_skip (void)
11696 str = getenv ("SKIP_TEST_WRITE_FILE_4");
11697 if (str && strcmp (str, "1") == 0) return 1;
11698 str = getenv ("SKIP_TEST_WRITE_FILE");
11699 if (str && strcmp (str, "1") == 0) return 1;
11703 static int test_write_file_4 (void)
11705 if (test_write_file_4_skip ()) {
11706 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_4");
11710 /* InitBasicFS for test_write_file_4: create ext2 on /dev/sda1 */
11712 char device[] = "/dev/sda";
11714 suppress_error = 0;
11715 r = guestfs_blockdev_setrw (g, device);
11721 suppress_error = 0;
11722 r = guestfs_umount_all (g);
11728 suppress_error = 0;
11729 r = guestfs_lvm_remove_all (g);
11734 char device[] = "/dev/sda";
11735 char lines_0[] = ",";
11741 suppress_error = 0;
11742 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11747 char fstype[] = "ext2";
11748 char device[] = "/dev/sda1";
11750 suppress_error = 0;
11751 r = guestfs_mkfs (g, fstype, device);
11756 char device[] = "/dev/sda1";
11757 char mountpoint[] = "/";
11759 suppress_error = 0;
11760 r = guestfs_mount (g, device, mountpoint);
11764 /* TestOutput for write_file (4) */
11765 char expected[] = "\n\n\n";
11767 char path[] = "/new";
11768 char content[] = "\n\n\n";
11770 suppress_error = 0;
11771 r = guestfs_write_file (g, path, content, 0);
11776 char path[] = "/new";
11778 suppress_error = 0;
11779 r = guestfs_cat (g, path);
11782 if (strcmp (r, expected) != 0) {
11783 fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
11791 static int test_write_file_5_skip (void)
11795 str = getenv ("SKIP_TEST_WRITE_FILE_5");
11796 if (str && strcmp (str, "1") == 0) return 1;
11797 str = getenv ("SKIP_TEST_WRITE_FILE");
11798 if (str && strcmp (str, "1") == 0) return 1;
11802 static int test_write_file_5 (void)
11804 if (test_write_file_5_skip ()) {
11805 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_5");
11809 /* InitBasicFS for test_write_file_5: create ext2 on /dev/sda1 */
11811 char device[] = "/dev/sda";
11813 suppress_error = 0;
11814 r = guestfs_blockdev_setrw (g, device);
11820 suppress_error = 0;
11821 r = guestfs_umount_all (g);
11827 suppress_error = 0;
11828 r = guestfs_lvm_remove_all (g);
11833 char device[] = "/dev/sda";
11834 char lines_0[] = ",";
11840 suppress_error = 0;
11841 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11846 char fstype[] = "ext2";
11847 char device[] = "/dev/sda1";
11849 suppress_error = 0;
11850 r = guestfs_mkfs (g, fstype, device);
11855 char device[] = "/dev/sda1";
11856 char mountpoint[] = "/";
11858 suppress_error = 0;
11859 r = guestfs_mount (g, device, mountpoint);
11863 /* TestOutput for write_file (5) */
11864 char expected[] = "\n";
11866 char path[] = "/new";
11867 char content[] = "\n";
11869 suppress_error = 0;
11870 r = guestfs_write_file (g, path, content, 0);
11875 char path[] = "/new";
11877 suppress_error = 0;
11878 r = guestfs_cat (g, path);
11881 if (strcmp (r, expected) != 0) {
11882 fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
11890 static int test_mkfs_0_skip (void)
11894 str = getenv ("SKIP_TEST_MKFS_0");
11895 if (str && strcmp (str, "1") == 0) return 1;
11896 str = getenv ("SKIP_TEST_MKFS");
11897 if (str && strcmp (str, "1") == 0) return 1;
11901 static int test_mkfs_0 (void)
11903 if (test_mkfs_0_skip ()) {
11904 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkfs_0");
11908 /* InitNone|InitEmpty for test_mkfs_0 */
11910 char device[] = "/dev/sda";
11912 suppress_error = 0;
11913 r = guestfs_blockdev_setrw (g, device);
11919 suppress_error = 0;
11920 r = guestfs_umount_all (g);
11926 suppress_error = 0;
11927 r = guestfs_lvm_remove_all (g);
11931 /* TestOutput for mkfs (0) */
11932 char expected[] = "new file contents";
11934 char device[] = "/dev/sda";
11935 char lines_0[] = ",";
11941 suppress_error = 0;
11942 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11947 char fstype[] = "ext2";
11948 char device[] = "/dev/sda1";
11950 suppress_error = 0;
11951 r = guestfs_mkfs (g, fstype, device);
11956 char device[] = "/dev/sda1";
11957 char mountpoint[] = "/";
11959 suppress_error = 0;
11960 r = guestfs_mount (g, device, mountpoint);
11965 char path[] = "/new";
11966 char content[] = "new file contents";
11968 suppress_error = 0;
11969 r = guestfs_write_file (g, path, content, 0);
11974 char path[] = "/new";
11976 suppress_error = 0;
11977 r = guestfs_cat (g, path);
11980 if (strcmp (r, expected) != 0) {
11981 fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
11989 static int test_lvcreate_0_skip (void)
11993 str = getenv ("SKIP_TEST_LVCREATE_0");
11994 if (str && strcmp (str, "1") == 0) return 1;
11995 str = getenv ("SKIP_TEST_LVCREATE");
11996 if (str && strcmp (str, "1") == 0) return 1;
12000 static int test_lvcreate_0 (void)
12002 if (test_lvcreate_0_skip ()) {
12003 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvcreate_0");
12007 /* InitNone|InitEmpty for test_lvcreate_0 */
12009 char device[] = "/dev/sda";
12011 suppress_error = 0;
12012 r = guestfs_blockdev_setrw (g, device);
12018 suppress_error = 0;
12019 r = guestfs_umount_all (g);
12025 suppress_error = 0;
12026 r = guestfs_lvm_remove_all (g);
12030 /* TestOutputList for lvcreate (0) */
12032 char device[] = "/dev/sda";
12033 char lines_0[] = ",10";
12034 char lines_1[] = ",20";
12035 char lines_2[] = ",";
12043 suppress_error = 0;
12044 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12049 char device[] = "/dev/sda1";
12051 suppress_error = 0;
12052 r = guestfs_pvcreate (g, device);
12057 char device[] = "/dev/sda2";
12059 suppress_error = 0;
12060 r = guestfs_pvcreate (g, device);
12065 char device[] = "/dev/sda3";
12067 suppress_error = 0;
12068 r = guestfs_pvcreate (g, device);
12073 char volgroup[] = "VG1";
12074 char physvols_0[] = "/dev/sda1";
12075 char physvols_1[] = "/dev/sda2";
12076 char *physvols[] = {
12082 suppress_error = 0;
12083 r = guestfs_vgcreate (g, volgroup, physvols);
12088 char volgroup[] = "VG2";
12089 char physvols_0[] = "/dev/sda3";
12090 char *physvols[] = {
12095 suppress_error = 0;
12096 r = guestfs_vgcreate (g, volgroup, physvols);
12101 char logvol[] = "LV1";
12102 char volgroup[] = "VG1";
12104 suppress_error = 0;
12105 r = guestfs_lvcreate (g, logvol, volgroup, 50);
12110 char logvol[] = "LV2";
12111 char volgroup[] = "VG1";
12113 suppress_error = 0;
12114 r = guestfs_lvcreate (g, logvol, volgroup, 50);
12119 char logvol[] = "LV3";
12120 char volgroup[] = "VG2";
12122 suppress_error = 0;
12123 r = guestfs_lvcreate (g, logvol, volgroup, 50);
12128 char logvol[] = "LV4";
12129 char volgroup[] = "VG2";
12131 suppress_error = 0;
12132 r = guestfs_lvcreate (g, logvol, volgroup, 50);
12137 char logvol[] = "LV5";
12138 char volgroup[] = "VG2";
12140 suppress_error = 0;
12141 r = guestfs_lvcreate (g, logvol, volgroup, 50);
12148 suppress_error = 0;
12149 r = guestfs_lvs (g);
12153 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
12158 char expected[] = "/dev/VG1/LV1";
12159 if (strcmp (r[0], expected) != 0) {
12160 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
12165 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
12170 char expected[] = "/dev/VG1/LV2";
12171 if (strcmp (r[1], expected) != 0) {
12172 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
12177 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
12182 char expected[] = "/dev/VG2/LV3";
12183 if (strcmp (r[2], expected) != 0) {
12184 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
12189 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
12194 char expected[] = "/dev/VG2/LV4";
12195 if (strcmp (r[3], expected) != 0) {
12196 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
12201 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
12206 char expected[] = "/dev/VG2/LV5";
12207 if (strcmp (r[4], expected) != 0) {
12208 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
12212 if (r[5] != NULL) {
12213 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
12217 for (i = 0; r[i] != NULL; ++i)
12224 static int test_vgcreate_0_skip (void)
12228 str = getenv ("SKIP_TEST_VGCREATE_0");
12229 if (str && strcmp (str, "1") == 0) return 1;
12230 str = getenv ("SKIP_TEST_VGCREATE");
12231 if (str && strcmp (str, "1") == 0) return 1;
12235 static int test_vgcreate_0 (void)
12237 if (test_vgcreate_0_skip ()) {
12238 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgcreate_0");
12242 /* InitNone|InitEmpty for test_vgcreate_0 */
12244 char device[] = "/dev/sda";
12246 suppress_error = 0;
12247 r = guestfs_blockdev_setrw (g, device);
12253 suppress_error = 0;
12254 r = guestfs_umount_all (g);
12260 suppress_error = 0;
12261 r = guestfs_lvm_remove_all (g);
12265 /* TestOutputList for vgcreate (0) */
12267 char device[] = "/dev/sda";
12268 char lines_0[] = ",10";
12269 char lines_1[] = ",20";
12270 char lines_2[] = ",";
12278 suppress_error = 0;
12279 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12284 char device[] = "/dev/sda1";
12286 suppress_error = 0;
12287 r = guestfs_pvcreate (g, device);
12292 char device[] = "/dev/sda2";
12294 suppress_error = 0;
12295 r = guestfs_pvcreate (g, device);
12300 char device[] = "/dev/sda3";
12302 suppress_error = 0;
12303 r = guestfs_pvcreate (g, device);
12308 char volgroup[] = "VG1";
12309 char physvols_0[] = "/dev/sda1";
12310 char physvols_1[] = "/dev/sda2";
12311 char *physvols[] = {
12317 suppress_error = 0;
12318 r = guestfs_vgcreate (g, volgroup, physvols);
12323 char volgroup[] = "VG2";
12324 char physvols_0[] = "/dev/sda3";
12325 char *physvols[] = {
12330 suppress_error = 0;
12331 r = guestfs_vgcreate (g, volgroup, physvols);
12338 suppress_error = 0;
12339 r = guestfs_vgs (g);
12343 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
12348 char expected[] = "VG1";
12349 if (strcmp (r[0], expected) != 0) {
12350 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
12355 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
12360 char expected[] = "VG2";
12361 if (strcmp (r[1], expected) != 0) {
12362 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
12366 if (r[2] != NULL) {
12367 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
12371 for (i = 0; r[i] != NULL; ++i)
12378 static int test_pvcreate_0_skip (void)
12382 str = getenv ("SKIP_TEST_PVCREATE_0");
12383 if (str && strcmp (str, "1") == 0) return 1;
12384 str = getenv ("SKIP_TEST_PVCREATE");
12385 if (str && strcmp (str, "1") == 0) return 1;
12389 static int test_pvcreate_0 (void)
12391 if (test_pvcreate_0_skip ()) {
12392 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvcreate_0");
12396 /* InitNone|InitEmpty for test_pvcreate_0 */
12398 char device[] = "/dev/sda";
12400 suppress_error = 0;
12401 r = guestfs_blockdev_setrw (g, device);
12407 suppress_error = 0;
12408 r = guestfs_umount_all (g);
12414 suppress_error = 0;
12415 r = guestfs_lvm_remove_all (g);
12419 /* TestOutputListOfDevices for pvcreate (0) */
12421 char device[] = "/dev/sda";
12422 char lines_0[] = ",10";
12423 char lines_1[] = ",20";
12424 char lines_2[] = ",";
12432 suppress_error = 0;
12433 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12438 char device[] = "/dev/sda1";
12440 suppress_error = 0;
12441 r = guestfs_pvcreate (g, device);
12446 char device[] = "/dev/sda2";
12448 suppress_error = 0;
12449 r = guestfs_pvcreate (g, device);
12454 char device[] = "/dev/sda3";
12456 suppress_error = 0;
12457 r = guestfs_pvcreate (g, device);
12464 suppress_error = 0;
12465 r = guestfs_pvs (g);
12469 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
12474 char expected[] = "/dev/sda1";
12476 if (strcmp (r[0], expected) != 0) {
12477 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
12482 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
12487 char expected[] = "/dev/sda2";
12489 if (strcmp (r[1], expected) != 0) {
12490 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
12495 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
12500 char expected[] = "/dev/sda3";
12502 if (strcmp (r[2], expected) != 0) {
12503 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
12507 if (r[3] != NULL) {
12508 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
12512 for (i = 0; r[i] != NULL; ++i)
12519 static int test_is_dir_0_skip (void)
12523 str = getenv ("SKIP_TEST_IS_DIR_0");
12524 if (str && strcmp (str, "1") == 0) return 1;
12525 str = getenv ("SKIP_TEST_IS_DIR");
12526 if (str && strcmp (str, "1") == 0) return 1;
12530 static int test_is_dir_0 (void)
12532 if (test_is_dir_0_skip ()) {
12533 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_0");
12537 /* InitBasicFS for test_is_dir_0: create ext2 on /dev/sda1 */
12539 char device[] = "/dev/sda";
12541 suppress_error = 0;
12542 r = guestfs_blockdev_setrw (g, device);
12548 suppress_error = 0;
12549 r = guestfs_umount_all (g);
12555 suppress_error = 0;
12556 r = guestfs_lvm_remove_all (g);
12561 char device[] = "/dev/sda";
12562 char lines_0[] = ",";
12568 suppress_error = 0;
12569 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12574 char fstype[] = "ext2";
12575 char device[] = "/dev/sda1";
12577 suppress_error = 0;
12578 r = guestfs_mkfs (g, fstype, device);
12583 char device[] = "/dev/sda1";
12584 char mountpoint[] = "/";
12586 suppress_error = 0;
12587 r = guestfs_mount (g, device, mountpoint);
12591 /* TestOutputFalse for is_dir (0) */
12593 char path[] = "/new";
12595 suppress_error = 0;
12596 r = guestfs_touch (g, path);
12601 char path[] = "/new";
12603 suppress_error = 0;
12604 r = guestfs_is_dir (g, path);
12608 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
12615 static int test_is_dir_1_skip (void)
12619 str = getenv ("SKIP_TEST_IS_DIR_1");
12620 if (str && strcmp (str, "1") == 0) return 1;
12621 str = getenv ("SKIP_TEST_IS_DIR");
12622 if (str && strcmp (str, "1") == 0) return 1;
12626 static int test_is_dir_1 (void)
12628 if (test_is_dir_1_skip ()) {
12629 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_1");
12633 /* InitBasicFS for test_is_dir_1: create ext2 on /dev/sda1 */
12635 char device[] = "/dev/sda";
12637 suppress_error = 0;
12638 r = guestfs_blockdev_setrw (g, device);
12644 suppress_error = 0;
12645 r = guestfs_umount_all (g);
12651 suppress_error = 0;
12652 r = guestfs_lvm_remove_all (g);
12657 char device[] = "/dev/sda";
12658 char lines_0[] = ",";
12664 suppress_error = 0;
12665 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12670 char fstype[] = "ext2";
12671 char device[] = "/dev/sda1";
12673 suppress_error = 0;
12674 r = guestfs_mkfs (g, fstype, device);
12679 char device[] = "/dev/sda1";
12680 char mountpoint[] = "/";
12682 suppress_error = 0;
12683 r = guestfs_mount (g, device, mountpoint);
12687 /* TestOutputTrue for is_dir (1) */
12689 char path[] = "/new";
12691 suppress_error = 0;
12692 r = guestfs_mkdir (g, path);
12697 char path[] = "/new";
12699 suppress_error = 0;
12700 r = guestfs_is_dir (g, path);
12704 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
12711 static int test_is_file_0_skip (void)
12715 str = getenv ("SKIP_TEST_IS_FILE_0");
12716 if (str && strcmp (str, "1") == 0) return 1;
12717 str = getenv ("SKIP_TEST_IS_FILE");
12718 if (str && strcmp (str, "1") == 0) return 1;
12722 static int test_is_file_0 (void)
12724 if (test_is_file_0_skip ()) {
12725 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_0");
12729 /* InitBasicFS for test_is_file_0: create ext2 on /dev/sda1 */
12731 char device[] = "/dev/sda";
12733 suppress_error = 0;
12734 r = guestfs_blockdev_setrw (g, device);
12740 suppress_error = 0;
12741 r = guestfs_umount_all (g);
12747 suppress_error = 0;
12748 r = guestfs_lvm_remove_all (g);
12753 char device[] = "/dev/sda";
12754 char lines_0[] = ",";
12760 suppress_error = 0;
12761 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12766 char fstype[] = "ext2";
12767 char device[] = "/dev/sda1";
12769 suppress_error = 0;
12770 r = guestfs_mkfs (g, fstype, device);
12775 char device[] = "/dev/sda1";
12776 char mountpoint[] = "/";
12778 suppress_error = 0;
12779 r = guestfs_mount (g, device, mountpoint);
12783 /* TestOutputTrue for is_file (0) */
12785 char path[] = "/new";
12787 suppress_error = 0;
12788 r = guestfs_touch (g, path);
12793 char path[] = "/new";
12795 suppress_error = 0;
12796 r = guestfs_is_file (g, path);
12800 fprintf (stderr, "test_is_file_0: expected true, got false\n");
12807 static int test_is_file_1_skip (void)
12811 str = getenv ("SKIP_TEST_IS_FILE_1");
12812 if (str && strcmp (str, "1") == 0) return 1;
12813 str = getenv ("SKIP_TEST_IS_FILE");
12814 if (str && strcmp (str, "1") == 0) return 1;
12818 static int test_is_file_1 (void)
12820 if (test_is_file_1_skip ()) {
12821 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_1");
12825 /* InitBasicFS for test_is_file_1: create ext2 on /dev/sda1 */
12827 char device[] = "/dev/sda";
12829 suppress_error = 0;
12830 r = guestfs_blockdev_setrw (g, device);
12836 suppress_error = 0;
12837 r = guestfs_umount_all (g);
12843 suppress_error = 0;
12844 r = guestfs_lvm_remove_all (g);
12849 char device[] = "/dev/sda";
12850 char lines_0[] = ",";
12856 suppress_error = 0;
12857 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12862 char fstype[] = "ext2";
12863 char device[] = "/dev/sda1";
12865 suppress_error = 0;
12866 r = guestfs_mkfs (g, fstype, device);
12871 char device[] = "/dev/sda1";
12872 char mountpoint[] = "/";
12874 suppress_error = 0;
12875 r = guestfs_mount (g, device, mountpoint);
12879 /* TestOutputFalse for is_file (1) */
12881 char path[] = "/new";
12883 suppress_error = 0;
12884 r = guestfs_mkdir (g, path);
12889 char path[] = "/new";
12891 suppress_error = 0;
12892 r = guestfs_is_file (g, path);
12896 fprintf (stderr, "test_is_file_1: expected false, got true\n");
12903 static int test_exists_0_skip (void)
12907 str = getenv ("SKIP_TEST_EXISTS_0");
12908 if (str && strcmp (str, "1") == 0) return 1;
12909 str = getenv ("SKIP_TEST_EXISTS");
12910 if (str && strcmp (str, "1") == 0) return 1;
12914 static int test_exists_0 (void)
12916 if (test_exists_0_skip ()) {
12917 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_0");
12921 /* InitBasicFS for test_exists_0: create ext2 on /dev/sda1 */
12923 char device[] = "/dev/sda";
12925 suppress_error = 0;
12926 r = guestfs_blockdev_setrw (g, device);
12932 suppress_error = 0;
12933 r = guestfs_umount_all (g);
12939 suppress_error = 0;
12940 r = guestfs_lvm_remove_all (g);
12945 char device[] = "/dev/sda";
12946 char lines_0[] = ",";
12952 suppress_error = 0;
12953 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12958 char fstype[] = "ext2";
12959 char device[] = "/dev/sda1";
12961 suppress_error = 0;
12962 r = guestfs_mkfs (g, fstype, device);
12967 char device[] = "/dev/sda1";
12968 char mountpoint[] = "/";
12970 suppress_error = 0;
12971 r = guestfs_mount (g, device, mountpoint);
12975 /* TestOutputTrue for exists (0) */
12977 char path[] = "/new";
12979 suppress_error = 0;
12980 r = guestfs_touch (g, path);
12985 char path[] = "/new";
12987 suppress_error = 0;
12988 r = guestfs_exists (g, path);
12992 fprintf (stderr, "test_exists_0: expected true, got false\n");
12999 static int test_exists_1_skip (void)
13003 str = getenv ("SKIP_TEST_EXISTS_1");
13004 if (str && strcmp (str, "1") == 0) return 1;
13005 str = getenv ("SKIP_TEST_EXISTS");
13006 if (str && strcmp (str, "1") == 0) return 1;
13010 static int test_exists_1 (void)
13012 if (test_exists_1_skip ()) {
13013 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_1");
13017 /* InitBasicFS for test_exists_1: create ext2 on /dev/sda1 */
13019 char device[] = "/dev/sda";
13021 suppress_error = 0;
13022 r = guestfs_blockdev_setrw (g, device);
13028 suppress_error = 0;
13029 r = guestfs_umount_all (g);
13035 suppress_error = 0;
13036 r = guestfs_lvm_remove_all (g);
13041 char device[] = "/dev/sda";
13042 char lines_0[] = ",";
13048 suppress_error = 0;
13049 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13054 char fstype[] = "ext2";
13055 char device[] = "/dev/sda1";
13057 suppress_error = 0;
13058 r = guestfs_mkfs (g, fstype, device);
13063 char device[] = "/dev/sda1";
13064 char mountpoint[] = "/";
13066 suppress_error = 0;
13067 r = guestfs_mount (g, device, mountpoint);
13071 /* TestOutputTrue for exists (1) */
13073 char path[] = "/new";
13075 suppress_error = 0;
13076 r = guestfs_mkdir (g, path);
13081 char path[] = "/new";
13083 suppress_error = 0;
13084 r = guestfs_exists (g, path);
13088 fprintf (stderr, "test_exists_1: expected true, got false\n");
13095 static int test_mkdir_p_0_skip (void)
13099 str = getenv ("SKIP_TEST_MKDIR_P_0");
13100 if (str && strcmp (str, "1") == 0) return 1;
13101 str = getenv ("SKIP_TEST_MKDIR_P");
13102 if (str && strcmp (str, "1") == 0) return 1;
13106 static int test_mkdir_p_0 (void)
13108 if (test_mkdir_p_0_skip ()) {
13109 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_0");
13113 /* InitBasicFS for test_mkdir_p_0: create ext2 on /dev/sda1 */
13115 char device[] = "/dev/sda";
13117 suppress_error = 0;
13118 r = guestfs_blockdev_setrw (g, device);
13124 suppress_error = 0;
13125 r = guestfs_umount_all (g);
13131 suppress_error = 0;
13132 r = guestfs_lvm_remove_all (g);
13137 char device[] = "/dev/sda";
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";
13153 suppress_error = 0;
13154 r = guestfs_mkfs (g, fstype, device);
13159 char device[] = "/dev/sda1";
13160 char mountpoint[] = "/";
13162 suppress_error = 0;
13163 r = guestfs_mount (g, device, mountpoint);
13167 /* TestOutputTrue for mkdir_p (0) */
13169 char path[] = "/new/foo/bar";
13171 suppress_error = 0;
13172 r = guestfs_mkdir_p (g, path);
13177 char path[] = "/new/foo/bar";
13179 suppress_error = 0;
13180 r = guestfs_is_dir (g, path);
13184 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
13191 static int test_mkdir_p_1_skip (void)
13195 str = getenv ("SKIP_TEST_MKDIR_P_1");
13196 if (str && strcmp (str, "1") == 0) return 1;
13197 str = getenv ("SKIP_TEST_MKDIR_P");
13198 if (str && strcmp (str, "1") == 0) return 1;
13202 static int test_mkdir_p_1 (void)
13204 if (test_mkdir_p_1_skip ()) {
13205 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_1");
13209 /* InitBasicFS for test_mkdir_p_1: create ext2 on /dev/sda1 */
13211 char device[] = "/dev/sda";
13213 suppress_error = 0;
13214 r = guestfs_blockdev_setrw (g, device);
13220 suppress_error = 0;
13221 r = guestfs_umount_all (g);
13227 suppress_error = 0;
13228 r = guestfs_lvm_remove_all (g);
13233 char device[] = "/dev/sda";
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";
13249 suppress_error = 0;
13250 r = guestfs_mkfs (g, fstype, device);
13255 char device[] = "/dev/sda1";
13256 char mountpoint[] = "/";
13258 suppress_error = 0;
13259 r = guestfs_mount (g, device, mountpoint);
13263 /* TestOutputTrue for mkdir_p (1) */
13265 char path[] = "/new/foo/bar";
13267 suppress_error = 0;
13268 r = guestfs_mkdir_p (g, path);
13273 char path[] = "/new/foo";
13275 suppress_error = 0;
13276 r = guestfs_is_dir (g, path);
13280 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
13287 static int test_mkdir_p_2_skip (void)
13291 str = getenv ("SKIP_TEST_MKDIR_P_2");
13292 if (str && strcmp (str, "1") == 0) return 1;
13293 str = getenv ("SKIP_TEST_MKDIR_P");
13294 if (str && strcmp (str, "1") == 0) return 1;
13298 static int test_mkdir_p_2 (void)
13300 if (test_mkdir_p_2_skip ()) {
13301 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_2");
13305 /* InitBasicFS for test_mkdir_p_2: create ext2 on /dev/sda1 */
13307 char device[] = "/dev/sda";
13309 suppress_error = 0;
13310 r = guestfs_blockdev_setrw (g, device);
13316 suppress_error = 0;
13317 r = guestfs_umount_all (g);
13323 suppress_error = 0;
13324 r = guestfs_lvm_remove_all (g);
13329 char device[] = "/dev/sda";
13330 char lines_0[] = ",";
13336 suppress_error = 0;
13337 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13342 char fstype[] = "ext2";
13343 char device[] = "/dev/sda1";
13345 suppress_error = 0;
13346 r = guestfs_mkfs (g, fstype, device);
13351 char device[] = "/dev/sda1";
13352 char mountpoint[] = "/";
13354 suppress_error = 0;
13355 r = guestfs_mount (g, device, mountpoint);
13359 /* TestOutputTrue for mkdir_p (2) */
13361 char path[] = "/new/foo/bar";
13363 suppress_error = 0;
13364 r = guestfs_mkdir_p (g, path);
13369 char path[] = "/new";
13371 suppress_error = 0;
13372 r = guestfs_is_dir (g, path);
13376 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
13383 static int test_mkdir_p_3_skip (void)
13387 str = getenv ("SKIP_TEST_MKDIR_P_3");
13388 if (str && strcmp (str, "1") == 0) return 1;
13389 str = getenv ("SKIP_TEST_MKDIR_P");
13390 if (str && strcmp (str, "1") == 0) return 1;
13394 static int test_mkdir_p_3 (void)
13396 if (test_mkdir_p_3_skip ()) {
13397 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_3");
13401 /* InitBasicFS for test_mkdir_p_3: create ext2 on /dev/sda1 */
13403 char device[] = "/dev/sda";
13405 suppress_error = 0;
13406 r = guestfs_blockdev_setrw (g, device);
13412 suppress_error = 0;
13413 r = guestfs_umount_all (g);
13419 suppress_error = 0;
13420 r = guestfs_lvm_remove_all (g);
13425 char device[] = "/dev/sda";
13426 char lines_0[] = ",";
13432 suppress_error = 0;
13433 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13438 char fstype[] = "ext2";
13439 char device[] = "/dev/sda1";
13441 suppress_error = 0;
13442 r = guestfs_mkfs (g, fstype, device);
13447 char device[] = "/dev/sda1";
13448 char mountpoint[] = "/";
13450 suppress_error = 0;
13451 r = guestfs_mount (g, device, mountpoint);
13455 /* TestRun for mkdir_p (3) */
13457 char path[] = "/new";
13459 suppress_error = 0;
13460 r = guestfs_mkdir (g, path);
13465 char path[] = "/new";
13467 suppress_error = 0;
13468 r = guestfs_mkdir_p (g, path);
13475 static int test_mkdir_p_4_skip (void)
13479 str = getenv ("SKIP_TEST_MKDIR_P_4");
13480 if (str && strcmp (str, "1") == 0) return 1;
13481 str = getenv ("SKIP_TEST_MKDIR_P");
13482 if (str && strcmp (str, "1") == 0) return 1;
13486 static int test_mkdir_p_4 (void)
13488 if (test_mkdir_p_4_skip ()) {
13489 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_4");
13493 /* InitBasicFS for test_mkdir_p_4: create ext2 on /dev/sda1 */
13495 char device[] = "/dev/sda";
13497 suppress_error = 0;
13498 r = guestfs_blockdev_setrw (g, device);
13504 suppress_error = 0;
13505 r = guestfs_umount_all (g);
13511 suppress_error = 0;
13512 r = guestfs_lvm_remove_all (g);
13517 char device[] = "/dev/sda";
13518 char lines_0[] = ",";
13524 suppress_error = 0;
13525 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13530 char fstype[] = "ext2";
13531 char device[] = "/dev/sda1";
13533 suppress_error = 0;
13534 r = guestfs_mkfs (g, fstype, device);
13539 char device[] = "/dev/sda1";
13540 char mountpoint[] = "/";
13542 suppress_error = 0;
13543 r = guestfs_mount (g, device, mountpoint);
13547 /* TestLastFail for mkdir_p (4) */
13549 char path[] = "/new";
13551 suppress_error = 0;
13552 r = guestfs_touch (g, path);
13557 char path[] = "/new";
13559 suppress_error = 1;
13560 r = guestfs_mkdir_p (g, path);
13567 static int test_mkdir_0_skip (void)
13571 str = getenv ("SKIP_TEST_MKDIR_0");
13572 if (str && strcmp (str, "1") == 0) return 1;
13573 str = getenv ("SKIP_TEST_MKDIR");
13574 if (str && strcmp (str, "1") == 0) return 1;
13578 static int test_mkdir_0 (void)
13580 if (test_mkdir_0_skip ()) {
13581 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_0");
13585 /* InitBasicFS for test_mkdir_0: create ext2 on /dev/sda1 */
13587 char device[] = "/dev/sda";
13589 suppress_error = 0;
13590 r = guestfs_blockdev_setrw (g, device);
13596 suppress_error = 0;
13597 r = guestfs_umount_all (g);
13603 suppress_error = 0;
13604 r = guestfs_lvm_remove_all (g);
13609 char device[] = "/dev/sda";
13610 char lines_0[] = ",";
13616 suppress_error = 0;
13617 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13622 char fstype[] = "ext2";
13623 char device[] = "/dev/sda1";
13625 suppress_error = 0;
13626 r = guestfs_mkfs (g, fstype, device);
13631 char device[] = "/dev/sda1";
13632 char mountpoint[] = "/";
13634 suppress_error = 0;
13635 r = guestfs_mount (g, device, mountpoint);
13639 /* TestOutputTrue for mkdir (0) */
13641 char path[] = "/new";
13643 suppress_error = 0;
13644 r = guestfs_mkdir (g, path);
13649 char path[] = "/new";
13651 suppress_error = 0;
13652 r = guestfs_is_dir (g, path);
13656 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
13663 static int test_mkdir_1_skip (void)
13667 str = getenv ("SKIP_TEST_MKDIR_1");
13668 if (str && strcmp (str, "1") == 0) return 1;
13669 str = getenv ("SKIP_TEST_MKDIR");
13670 if (str && strcmp (str, "1") == 0) return 1;
13674 static int test_mkdir_1 (void)
13676 if (test_mkdir_1_skip ()) {
13677 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_1");
13681 /* InitBasicFS for test_mkdir_1: create ext2 on /dev/sda1 */
13683 char device[] = "/dev/sda";
13685 suppress_error = 0;
13686 r = guestfs_blockdev_setrw (g, device);
13692 suppress_error = 0;
13693 r = guestfs_umount_all (g);
13699 suppress_error = 0;
13700 r = guestfs_lvm_remove_all (g);
13705 char device[] = "/dev/sda";
13706 char lines_0[] = ",";
13712 suppress_error = 0;
13713 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13718 char fstype[] = "ext2";
13719 char device[] = "/dev/sda1";
13721 suppress_error = 0;
13722 r = guestfs_mkfs (g, fstype, device);
13727 char device[] = "/dev/sda1";
13728 char mountpoint[] = "/";
13730 suppress_error = 0;
13731 r = guestfs_mount (g, device, mountpoint);
13735 /* TestLastFail for mkdir (1) */
13737 char path[] = "/new/foo/bar";
13739 suppress_error = 1;
13740 r = guestfs_mkdir (g, path);
13747 static int test_rm_rf_0_skip (void)
13751 str = getenv ("SKIP_TEST_RM_RF_0");
13752 if (str && strcmp (str, "1") == 0) return 1;
13753 str = getenv ("SKIP_TEST_RM_RF");
13754 if (str && strcmp (str, "1") == 0) return 1;
13758 static int test_rm_rf_0 (void)
13760 if (test_rm_rf_0_skip ()) {
13761 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_rf_0");
13765 /* InitBasicFS for test_rm_rf_0: create ext2 on /dev/sda1 */
13767 char device[] = "/dev/sda";
13769 suppress_error = 0;
13770 r = guestfs_blockdev_setrw (g, device);
13776 suppress_error = 0;
13777 r = guestfs_umount_all (g);
13783 suppress_error = 0;
13784 r = guestfs_lvm_remove_all (g);
13789 char device[] = "/dev/sda";
13790 char lines_0[] = ",";
13796 suppress_error = 0;
13797 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13802 char fstype[] = "ext2";
13803 char device[] = "/dev/sda1";
13805 suppress_error = 0;
13806 r = guestfs_mkfs (g, fstype, device);
13811 char device[] = "/dev/sda1";
13812 char mountpoint[] = "/";
13814 suppress_error = 0;
13815 r = guestfs_mount (g, device, mountpoint);
13819 /* TestOutputFalse for rm_rf (0) */
13821 char path[] = "/new";
13823 suppress_error = 0;
13824 r = guestfs_mkdir (g, path);
13829 char path[] = "/new/foo";
13831 suppress_error = 0;
13832 r = guestfs_mkdir (g, path);
13837 char path[] = "/new/foo/bar";
13839 suppress_error = 0;
13840 r = guestfs_touch (g, path);
13845 char path[] = "/new";
13847 suppress_error = 0;
13848 r = guestfs_rm_rf (g, path);
13853 char path[] = "/new";
13855 suppress_error = 0;
13856 r = guestfs_exists (g, path);
13860 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
13867 static int test_rmdir_0_skip (void)
13871 str = getenv ("SKIP_TEST_RMDIR_0");
13872 if (str && strcmp (str, "1") == 0) return 1;
13873 str = getenv ("SKIP_TEST_RMDIR");
13874 if (str && strcmp (str, "1") == 0) return 1;
13878 static int test_rmdir_0 (void)
13880 if (test_rmdir_0_skip ()) {
13881 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_0");
13885 /* InitBasicFS for test_rmdir_0: create ext2 on /dev/sda1 */
13887 char device[] = "/dev/sda";
13889 suppress_error = 0;
13890 r = guestfs_blockdev_setrw (g, device);
13896 suppress_error = 0;
13897 r = guestfs_umount_all (g);
13903 suppress_error = 0;
13904 r = guestfs_lvm_remove_all (g);
13909 char device[] = "/dev/sda";
13910 char lines_0[] = ",";
13916 suppress_error = 0;
13917 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13922 char fstype[] = "ext2";
13923 char device[] = "/dev/sda1";
13925 suppress_error = 0;
13926 r = guestfs_mkfs (g, fstype, device);
13931 char device[] = "/dev/sda1";
13932 char mountpoint[] = "/";
13934 suppress_error = 0;
13935 r = guestfs_mount (g, device, mountpoint);
13939 /* TestRun for rmdir (0) */
13941 char path[] = "/new";
13943 suppress_error = 0;
13944 r = guestfs_mkdir (g, path);
13949 char path[] = "/new";
13951 suppress_error = 0;
13952 r = guestfs_rmdir (g, path);
13959 static int test_rmdir_1_skip (void)
13963 str = getenv ("SKIP_TEST_RMDIR_1");
13964 if (str && strcmp (str, "1") == 0) return 1;
13965 str = getenv ("SKIP_TEST_RMDIR");
13966 if (str && strcmp (str, "1") == 0) return 1;
13970 static int test_rmdir_1 (void)
13972 if (test_rmdir_1_skip ()) {
13973 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_1");
13977 /* InitBasicFS for test_rmdir_1: create ext2 on /dev/sda1 */
13979 char device[] = "/dev/sda";
13981 suppress_error = 0;
13982 r = guestfs_blockdev_setrw (g, device);
13988 suppress_error = 0;
13989 r = guestfs_umount_all (g);
13995 suppress_error = 0;
13996 r = guestfs_lvm_remove_all (g);
14001 char device[] = "/dev/sda";
14002 char lines_0[] = ",";
14008 suppress_error = 0;
14009 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14014 char fstype[] = "ext2";
14015 char device[] = "/dev/sda1";
14017 suppress_error = 0;
14018 r = guestfs_mkfs (g, fstype, device);
14023 char device[] = "/dev/sda1";
14024 char mountpoint[] = "/";
14026 suppress_error = 0;
14027 r = guestfs_mount (g, device, mountpoint);
14031 /* TestLastFail for rmdir (1) */
14033 char path[] = "/new";
14035 suppress_error = 1;
14036 r = guestfs_rmdir (g, path);
14043 static int test_rmdir_2_skip (void)
14047 str = getenv ("SKIP_TEST_RMDIR_2");
14048 if (str && strcmp (str, "1") == 0) return 1;
14049 str = getenv ("SKIP_TEST_RMDIR");
14050 if (str && strcmp (str, "1") == 0) return 1;
14054 static int test_rmdir_2 (void)
14056 if (test_rmdir_2_skip ()) {
14057 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_2");
14061 /* InitBasicFS for test_rmdir_2: create ext2 on /dev/sda1 */
14063 char device[] = "/dev/sda";
14065 suppress_error = 0;
14066 r = guestfs_blockdev_setrw (g, device);
14072 suppress_error = 0;
14073 r = guestfs_umount_all (g);
14079 suppress_error = 0;
14080 r = guestfs_lvm_remove_all (g);
14085 char device[] = "/dev/sda";
14086 char lines_0[] = ",";
14092 suppress_error = 0;
14093 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14098 char fstype[] = "ext2";
14099 char device[] = "/dev/sda1";
14101 suppress_error = 0;
14102 r = guestfs_mkfs (g, fstype, device);
14107 char device[] = "/dev/sda1";
14108 char mountpoint[] = "/";
14110 suppress_error = 0;
14111 r = guestfs_mount (g, device, mountpoint);
14115 /* TestLastFail for rmdir (2) */
14117 char path[] = "/new";
14119 suppress_error = 0;
14120 r = guestfs_touch (g, path);
14125 char path[] = "/new";
14127 suppress_error = 1;
14128 r = guestfs_rmdir (g, path);
14135 static int test_rm_0_skip (void)
14139 str = getenv ("SKIP_TEST_RM_0");
14140 if (str && strcmp (str, "1") == 0) return 1;
14141 str = getenv ("SKIP_TEST_RM");
14142 if (str && strcmp (str, "1") == 0) return 1;
14146 static int test_rm_0 (void)
14148 if (test_rm_0_skip ()) {
14149 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_0");
14153 /* InitBasicFS for test_rm_0: create ext2 on /dev/sda1 */
14155 char device[] = "/dev/sda";
14157 suppress_error = 0;
14158 r = guestfs_blockdev_setrw (g, device);
14164 suppress_error = 0;
14165 r = guestfs_umount_all (g);
14171 suppress_error = 0;
14172 r = guestfs_lvm_remove_all (g);
14177 char device[] = "/dev/sda";
14178 char lines_0[] = ",";
14184 suppress_error = 0;
14185 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14190 char fstype[] = "ext2";
14191 char device[] = "/dev/sda1";
14193 suppress_error = 0;
14194 r = guestfs_mkfs (g, fstype, device);
14199 char device[] = "/dev/sda1";
14200 char mountpoint[] = "/";
14202 suppress_error = 0;
14203 r = guestfs_mount (g, device, mountpoint);
14207 /* TestRun for rm (0) */
14209 char path[] = "/new";
14211 suppress_error = 0;
14212 r = guestfs_touch (g, path);
14217 char path[] = "/new";
14219 suppress_error = 0;
14220 r = guestfs_rm (g, path);
14227 static int test_rm_1_skip (void)
14231 str = getenv ("SKIP_TEST_RM_1");
14232 if (str && strcmp (str, "1") == 0) return 1;
14233 str = getenv ("SKIP_TEST_RM");
14234 if (str && strcmp (str, "1") == 0) return 1;
14238 static int test_rm_1 (void)
14240 if (test_rm_1_skip ()) {
14241 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_1");
14245 /* InitBasicFS for test_rm_1: create ext2 on /dev/sda1 */
14247 char device[] = "/dev/sda";
14249 suppress_error = 0;
14250 r = guestfs_blockdev_setrw (g, device);
14256 suppress_error = 0;
14257 r = guestfs_umount_all (g);
14263 suppress_error = 0;
14264 r = guestfs_lvm_remove_all (g);
14269 char device[] = "/dev/sda";
14270 char lines_0[] = ",";
14276 suppress_error = 0;
14277 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14282 char fstype[] = "ext2";
14283 char device[] = "/dev/sda1";
14285 suppress_error = 0;
14286 r = guestfs_mkfs (g, fstype, device);
14291 char device[] = "/dev/sda1";
14292 char mountpoint[] = "/";
14294 suppress_error = 0;
14295 r = guestfs_mount (g, device, mountpoint);
14299 /* TestLastFail for rm (1) */
14301 char path[] = "/new";
14303 suppress_error = 1;
14304 r = guestfs_rm (g, path);
14311 static int test_rm_2_skip (void)
14315 str = getenv ("SKIP_TEST_RM_2");
14316 if (str && strcmp (str, "1") == 0) return 1;
14317 str = getenv ("SKIP_TEST_RM");
14318 if (str && strcmp (str, "1") == 0) return 1;
14322 static int test_rm_2 (void)
14324 if (test_rm_2_skip ()) {
14325 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_2");
14329 /* InitBasicFS for test_rm_2: create ext2 on /dev/sda1 */
14331 char device[] = "/dev/sda";
14333 suppress_error = 0;
14334 r = guestfs_blockdev_setrw (g, device);
14340 suppress_error = 0;
14341 r = guestfs_umount_all (g);
14347 suppress_error = 0;
14348 r = guestfs_lvm_remove_all (g);
14353 char device[] = "/dev/sda";
14354 char lines_0[] = ",";
14360 suppress_error = 0;
14361 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14366 char fstype[] = "ext2";
14367 char device[] = "/dev/sda1";
14369 suppress_error = 0;
14370 r = guestfs_mkfs (g, fstype, device);
14375 char device[] = "/dev/sda1";
14376 char mountpoint[] = "/";
14378 suppress_error = 0;
14379 r = guestfs_mount (g, device, mountpoint);
14383 /* TestLastFail for rm (2) */
14385 char path[] = "/new";
14387 suppress_error = 0;
14388 r = guestfs_mkdir (g, path);
14393 char path[] = "/new";
14395 suppress_error = 1;
14396 r = guestfs_rm (g, path);
14403 static int test_read_lines_0_skip (void)
14407 str = getenv ("SKIP_TEST_READ_LINES_0");
14408 if (str && strcmp (str, "1") == 0) return 1;
14409 str = getenv ("SKIP_TEST_READ_LINES");
14410 if (str && strcmp (str, "1") == 0) return 1;
14414 static int test_read_lines_0 (void)
14416 if (test_read_lines_0_skip ()) {
14417 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_0");
14421 /* InitBasicFS for test_read_lines_0: create ext2 on /dev/sda1 */
14423 char device[] = "/dev/sda";
14425 suppress_error = 0;
14426 r = guestfs_blockdev_setrw (g, device);
14432 suppress_error = 0;
14433 r = guestfs_umount_all (g);
14439 suppress_error = 0;
14440 r = guestfs_lvm_remove_all (g);
14445 char device[] = "/dev/sda";
14446 char lines_0[] = ",";
14452 suppress_error = 0;
14453 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14458 char fstype[] = "ext2";
14459 char device[] = "/dev/sda1";
14461 suppress_error = 0;
14462 r = guestfs_mkfs (g, fstype, device);
14467 char device[] = "/dev/sda1";
14468 char mountpoint[] = "/";
14470 suppress_error = 0;
14471 r = guestfs_mount (g, device, mountpoint);
14475 /* TestOutputList for read_lines (0) */
14477 char path[] = "/new";
14478 char content[] = "line1\r\nline2\nline3";
14480 suppress_error = 0;
14481 r = guestfs_write_file (g, path, content, 0);
14486 char path[] = "/new";
14489 suppress_error = 0;
14490 r = guestfs_read_lines (g, path);
14494 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14499 char expected[] = "line1";
14500 if (strcmp (r[0], expected) != 0) {
14501 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14506 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14511 char expected[] = "line2";
14512 if (strcmp (r[1], expected) != 0) {
14513 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14518 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14523 char expected[] = "line3";
14524 if (strcmp (r[2], expected) != 0) {
14525 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14529 if (r[3] != NULL) {
14530 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
14534 for (i = 0; r[i] != NULL; ++i)
14541 static int test_read_lines_1_skip (void)
14545 str = getenv ("SKIP_TEST_READ_LINES_1");
14546 if (str && strcmp (str, "1") == 0) return 1;
14547 str = getenv ("SKIP_TEST_READ_LINES");
14548 if (str && strcmp (str, "1") == 0) return 1;
14552 static int test_read_lines_1 (void)
14554 if (test_read_lines_1_skip ()) {
14555 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_1");
14559 /* InitBasicFS for test_read_lines_1: create ext2 on /dev/sda1 */
14561 char device[] = "/dev/sda";
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 char lines_0[] = ",";
14590 suppress_error = 0;
14591 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14596 char fstype[] = "ext2";
14597 char device[] = "/dev/sda1";
14599 suppress_error = 0;
14600 r = guestfs_mkfs (g, fstype, device);
14605 char device[] = "/dev/sda1";
14606 char mountpoint[] = "/";
14608 suppress_error = 0;
14609 r = guestfs_mount (g, device, mountpoint);
14613 /* TestOutputList for read_lines (1) */
14615 char path[] = "/new";
14616 char content[] = "";
14618 suppress_error = 0;
14619 r = guestfs_write_file (g, path, content, 0);
14624 char path[] = "/new";
14627 suppress_error = 0;
14628 r = guestfs_read_lines (g, path);
14631 if (r[0] != NULL) {
14632 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
14636 for (i = 0; r[i] != NULL; ++i)
14643 static int test_lvs_0_skip (void)
14647 str = getenv ("SKIP_TEST_LVS_0");
14648 if (str && strcmp (str, "1") == 0) return 1;
14649 str = getenv ("SKIP_TEST_LVS");
14650 if (str && strcmp (str, "1") == 0) return 1;
14654 static int test_lvs_0 (void)
14656 if (test_lvs_0_skip ()) {
14657 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_0");
14661 /* InitBasicFSonLVM for test_lvs_0: create ext2 on /dev/VG/LV */
14663 char device[] = "/dev/sda";
14665 suppress_error = 0;
14666 r = guestfs_blockdev_setrw (g, device);
14672 suppress_error = 0;
14673 r = guestfs_umount_all (g);
14679 suppress_error = 0;
14680 r = guestfs_lvm_remove_all (g);
14685 char device[] = "/dev/sda";
14686 char lines_0[] = ",";
14692 suppress_error = 0;
14693 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14698 char device[] = "/dev/sda1";
14700 suppress_error = 0;
14701 r = guestfs_pvcreate (g, device);
14706 char volgroup[] = "VG";
14707 char physvols_0[] = "/dev/sda1";
14708 char *physvols[] = {
14713 suppress_error = 0;
14714 r = guestfs_vgcreate (g, volgroup, physvols);
14719 char logvol[] = "LV";
14720 char volgroup[] = "VG";
14722 suppress_error = 0;
14723 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14728 char fstype[] = "ext2";
14729 char device[] = "/dev/VG/LV";
14731 suppress_error = 0;
14732 r = guestfs_mkfs (g, fstype, device);
14737 char device[] = "/dev/VG/LV";
14738 char mountpoint[] = "/";
14740 suppress_error = 0;
14741 r = guestfs_mount (g, device, mountpoint);
14745 /* TestOutputList for lvs (0) */
14749 suppress_error = 0;
14750 r = guestfs_lvs (g);
14754 fprintf (stderr, "test_lvs_0: short list returned from command\n");
14759 char expected[] = "/dev/VG/LV";
14760 if (strcmp (r[0], expected) != 0) {
14761 fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14765 if (r[1] != NULL) {
14766 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
14770 for (i = 0; r[i] != NULL; ++i)
14777 static int test_lvs_1_skip (void)
14781 str = getenv ("SKIP_TEST_LVS_1");
14782 if (str && strcmp (str, "1") == 0) return 1;
14783 str = getenv ("SKIP_TEST_LVS");
14784 if (str && strcmp (str, "1") == 0) return 1;
14788 static int test_lvs_1 (void)
14790 if (test_lvs_1_skip ()) {
14791 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_1");
14795 /* InitNone|InitEmpty for test_lvs_1 */
14797 char device[] = "/dev/sda";
14799 suppress_error = 0;
14800 r = guestfs_blockdev_setrw (g, device);
14806 suppress_error = 0;
14807 r = guestfs_umount_all (g);
14813 suppress_error = 0;
14814 r = guestfs_lvm_remove_all (g);
14818 /* TestOutputList for lvs (1) */
14820 char device[] = "/dev/sda";
14821 char lines_0[] = ",10";
14822 char lines_1[] = ",20";
14823 char lines_2[] = ",";
14831 suppress_error = 0;
14832 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14837 char device[] = "/dev/sda1";
14839 suppress_error = 0;
14840 r = guestfs_pvcreate (g, device);
14845 char device[] = "/dev/sda2";
14847 suppress_error = 0;
14848 r = guestfs_pvcreate (g, device);
14853 char device[] = "/dev/sda3";
14855 suppress_error = 0;
14856 r = guestfs_pvcreate (g, device);
14861 char volgroup[] = "VG1";
14862 char physvols_0[] = "/dev/sda1";
14863 char physvols_1[] = "/dev/sda2";
14864 char *physvols[] = {
14870 suppress_error = 0;
14871 r = guestfs_vgcreate (g, volgroup, physvols);
14876 char volgroup[] = "VG2";
14877 char physvols_0[] = "/dev/sda3";
14878 char *physvols[] = {
14883 suppress_error = 0;
14884 r = guestfs_vgcreate (g, volgroup, physvols);
14889 char logvol[] = "LV1";
14890 char volgroup[] = "VG1";
14892 suppress_error = 0;
14893 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14898 char logvol[] = "LV2";
14899 char volgroup[] = "VG1";
14901 suppress_error = 0;
14902 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14907 char logvol[] = "LV3";
14908 char volgroup[] = "VG2";
14910 suppress_error = 0;
14911 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14918 suppress_error = 0;
14919 r = guestfs_lvs (g);
14923 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14928 char expected[] = "/dev/VG1/LV1";
14929 if (strcmp (r[0], expected) != 0) {
14930 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14935 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14940 char expected[] = "/dev/VG1/LV2";
14941 if (strcmp (r[1], expected) != 0) {
14942 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14947 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14952 char expected[] = "/dev/VG2/LV3";
14953 if (strcmp (r[2], expected) != 0) {
14954 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14958 if (r[3] != NULL) {
14959 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
14963 for (i = 0; r[i] != NULL; ++i)
14970 static int test_vgs_0_skip (void)
14974 str = getenv ("SKIP_TEST_VGS_0");
14975 if (str && strcmp (str, "1") == 0) return 1;
14976 str = getenv ("SKIP_TEST_VGS");
14977 if (str && strcmp (str, "1") == 0) return 1;
14981 static int test_vgs_0 (void)
14983 if (test_vgs_0_skip ()) {
14984 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_0");
14988 /* InitBasicFSonLVM for test_vgs_0: create ext2 on /dev/VG/LV */
14990 char device[] = "/dev/sda";
14992 suppress_error = 0;
14993 r = guestfs_blockdev_setrw (g, device);
14999 suppress_error = 0;
15000 r = guestfs_umount_all (g);
15006 suppress_error = 0;
15007 r = guestfs_lvm_remove_all (g);
15012 char device[] = "/dev/sda";
15013 char lines_0[] = ",";
15019 suppress_error = 0;
15020 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15025 char device[] = "/dev/sda1";
15027 suppress_error = 0;
15028 r = guestfs_pvcreate (g, device);
15033 char volgroup[] = "VG";
15034 char physvols_0[] = "/dev/sda1";
15035 char *physvols[] = {
15040 suppress_error = 0;
15041 r = guestfs_vgcreate (g, volgroup, physvols);
15046 char logvol[] = "LV";
15047 char volgroup[] = "VG";
15049 suppress_error = 0;
15050 r = guestfs_lvcreate (g, logvol, volgroup, 8);
15055 char fstype[] = "ext2";
15056 char device[] = "/dev/VG/LV";
15058 suppress_error = 0;
15059 r = guestfs_mkfs (g, fstype, device);
15064 char device[] = "/dev/VG/LV";
15065 char mountpoint[] = "/";
15067 suppress_error = 0;
15068 r = guestfs_mount (g, device, mountpoint);
15072 /* TestOutputList for vgs (0) */
15076 suppress_error = 0;
15077 r = guestfs_vgs (g);
15081 fprintf (stderr, "test_vgs_0: short list returned from command\n");
15086 char expected[] = "VG";
15087 if (strcmp (r[0], expected) != 0) {
15088 fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15092 if (r[1] != NULL) {
15093 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
15097 for (i = 0; r[i] != NULL; ++i)
15104 static int test_vgs_1_skip (void)
15108 str = getenv ("SKIP_TEST_VGS_1");
15109 if (str && strcmp (str, "1") == 0) return 1;
15110 str = getenv ("SKIP_TEST_VGS");
15111 if (str && strcmp (str, "1") == 0) return 1;
15115 static int test_vgs_1 (void)
15117 if (test_vgs_1_skip ()) {
15118 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_1");
15122 /* InitNone|InitEmpty for test_vgs_1 */
15124 char device[] = "/dev/sda";
15126 suppress_error = 0;
15127 r = guestfs_blockdev_setrw (g, device);
15133 suppress_error = 0;
15134 r = guestfs_umount_all (g);
15140 suppress_error = 0;
15141 r = guestfs_lvm_remove_all (g);
15145 /* TestOutputList for vgs (1) */
15147 char device[] = "/dev/sda";
15148 char lines_0[] = ",10";
15149 char lines_1[] = ",20";
15150 char lines_2[] = ",";
15158 suppress_error = 0;
15159 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15164 char device[] = "/dev/sda1";
15166 suppress_error = 0;
15167 r = guestfs_pvcreate (g, device);
15172 char device[] = "/dev/sda2";
15174 suppress_error = 0;
15175 r = guestfs_pvcreate (g, device);
15180 char device[] = "/dev/sda3";
15182 suppress_error = 0;
15183 r = guestfs_pvcreate (g, device);
15188 char volgroup[] = "VG1";
15189 char physvols_0[] = "/dev/sda1";
15190 char physvols_1[] = "/dev/sda2";
15191 char *physvols[] = {
15197 suppress_error = 0;
15198 r = guestfs_vgcreate (g, volgroup, physvols);
15203 char volgroup[] = "VG2";
15204 char physvols_0[] = "/dev/sda3";
15205 char *physvols[] = {
15210 suppress_error = 0;
15211 r = guestfs_vgcreate (g, volgroup, physvols);
15218 suppress_error = 0;
15219 r = guestfs_vgs (g);
15223 fprintf (stderr, "test_vgs_1: short list returned from command\n");
15228 char expected[] = "VG1";
15229 if (strcmp (r[0], expected) != 0) {
15230 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15235 fprintf (stderr, "test_vgs_1: short list returned from command\n");
15240 char expected[] = "VG2";
15241 if (strcmp (r[1], expected) != 0) {
15242 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15246 if (r[2] != NULL) {
15247 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
15251 for (i = 0; r[i] != NULL; ++i)
15258 static int test_pvs_0_skip (void)
15262 str = getenv ("SKIP_TEST_PVS_0");
15263 if (str && strcmp (str, "1") == 0) return 1;
15264 str = getenv ("SKIP_TEST_PVS");
15265 if (str && strcmp (str, "1") == 0) return 1;
15269 static int test_pvs_0 (void)
15271 if (test_pvs_0_skip ()) {
15272 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_0");
15276 /* InitBasicFSonLVM for test_pvs_0: create ext2 on /dev/VG/LV */
15278 char device[] = "/dev/sda";
15280 suppress_error = 0;
15281 r = guestfs_blockdev_setrw (g, device);
15287 suppress_error = 0;
15288 r = guestfs_umount_all (g);
15294 suppress_error = 0;
15295 r = guestfs_lvm_remove_all (g);
15300 char device[] = "/dev/sda";
15301 char lines_0[] = ",";
15307 suppress_error = 0;
15308 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15313 char device[] = "/dev/sda1";
15315 suppress_error = 0;
15316 r = guestfs_pvcreate (g, device);
15321 char volgroup[] = "VG";
15322 char physvols_0[] = "/dev/sda1";
15323 char *physvols[] = {
15328 suppress_error = 0;
15329 r = guestfs_vgcreate (g, volgroup, physvols);
15334 char logvol[] = "LV";
15335 char volgroup[] = "VG";
15337 suppress_error = 0;
15338 r = guestfs_lvcreate (g, logvol, volgroup, 8);
15343 char fstype[] = "ext2";
15344 char device[] = "/dev/VG/LV";
15346 suppress_error = 0;
15347 r = guestfs_mkfs (g, fstype, device);
15352 char device[] = "/dev/VG/LV";
15353 char mountpoint[] = "/";
15355 suppress_error = 0;
15356 r = guestfs_mount (g, device, mountpoint);
15360 /* TestOutputListOfDevices for pvs (0) */
15364 suppress_error = 0;
15365 r = guestfs_pvs (g);
15369 fprintf (stderr, "test_pvs_0: short list returned from command\n");
15374 char expected[] = "/dev/sda1";
15376 if (strcmp (r[0], expected) != 0) {
15377 fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15381 if (r[1] != NULL) {
15382 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
15386 for (i = 0; r[i] != NULL; ++i)
15393 static int test_pvs_1_skip (void)
15397 str = getenv ("SKIP_TEST_PVS_1");
15398 if (str && strcmp (str, "1") == 0) return 1;
15399 str = getenv ("SKIP_TEST_PVS");
15400 if (str && strcmp (str, "1") == 0) return 1;
15404 static int test_pvs_1 (void)
15406 if (test_pvs_1_skip ()) {
15407 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_1");
15411 /* InitNone|InitEmpty for test_pvs_1 */
15413 char device[] = "/dev/sda";
15415 suppress_error = 0;
15416 r = guestfs_blockdev_setrw (g, device);
15422 suppress_error = 0;
15423 r = guestfs_umount_all (g);
15429 suppress_error = 0;
15430 r = guestfs_lvm_remove_all (g);
15434 /* TestOutputListOfDevices for pvs (1) */
15436 char device[] = "/dev/sda";
15437 char lines_0[] = ",10";
15438 char lines_1[] = ",20";
15439 char lines_2[] = ",";
15447 suppress_error = 0;
15448 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15453 char device[] = "/dev/sda1";
15455 suppress_error = 0;
15456 r = guestfs_pvcreate (g, device);
15461 char device[] = "/dev/sda2";
15463 suppress_error = 0;
15464 r = guestfs_pvcreate (g, device);
15469 char device[] = "/dev/sda3";
15471 suppress_error = 0;
15472 r = guestfs_pvcreate (g, device);
15479 suppress_error = 0;
15480 r = guestfs_pvs (g);
15484 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15489 char expected[] = "/dev/sda1";
15491 if (strcmp (r[0], expected) != 0) {
15492 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15497 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15502 char expected[] = "/dev/sda2";
15504 if (strcmp (r[1], expected) != 0) {
15505 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15510 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15515 char expected[] = "/dev/sda3";
15517 if (strcmp (r[2], expected) != 0) {
15518 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15522 if (r[3] != NULL) {
15523 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
15527 for (i = 0; r[i] != NULL; ++i)
15534 static int test_list_partitions_0_skip (void)
15538 str = getenv ("SKIP_TEST_LIST_PARTITIONS_0");
15539 if (str && strcmp (str, "1") == 0) return 1;
15540 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
15541 if (str && strcmp (str, "1") == 0) return 1;
15545 static int test_list_partitions_0 (void)
15547 if (test_list_partitions_0_skip ()) {
15548 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_0");
15552 /* InitBasicFS for test_list_partitions_0: create ext2 on /dev/sda1 */
15554 char device[] = "/dev/sda";
15556 suppress_error = 0;
15557 r = guestfs_blockdev_setrw (g, device);
15563 suppress_error = 0;
15564 r = guestfs_umount_all (g);
15570 suppress_error = 0;
15571 r = guestfs_lvm_remove_all (g);
15576 char device[] = "/dev/sda";
15577 char lines_0[] = ",";
15583 suppress_error = 0;
15584 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15589 char fstype[] = "ext2";
15590 char device[] = "/dev/sda1";
15592 suppress_error = 0;
15593 r = guestfs_mkfs (g, fstype, device);
15598 char device[] = "/dev/sda1";
15599 char mountpoint[] = "/";
15601 suppress_error = 0;
15602 r = guestfs_mount (g, device, mountpoint);
15606 /* TestOutputListOfDevices for list_partitions (0) */
15610 suppress_error = 0;
15611 r = guestfs_list_partitions (g);
15615 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
15620 char expected[] = "/dev/sda1";
15622 if (strcmp (r[0], expected) != 0) {
15623 fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15627 if (r[1] != NULL) {
15628 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
15632 for (i = 0; r[i] != NULL; ++i)
15639 static int test_list_partitions_1_skip (void)
15643 str = getenv ("SKIP_TEST_LIST_PARTITIONS_1");
15644 if (str && strcmp (str, "1") == 0) return 1;
15645 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
15646 if (str && strcmp (str, "1") == 0) return 1;
15650 static int test_list_partitions_1 (void)
15652 if (test_list_partitions_1_skip ()) {
15653 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_1");
15657 /* InitNone|InitEmpty for test_list_partitions_1 */
15659 char device[] = "/dev/sda";
15661 suppress_error = 0;
15662 r = guestfs_blockdev_setrw (g, device);
15668 suppress_error = 0;
15669 r = guestfs_umount_all (g);
15675 suppress_error = 0;
15676 r = guestfs_lvm_remove_all (g);
15680 /* TestOutputListOfDevices for list_partitions (1) */
15682 char device[] = "/dev/sda";
15683 char lines_0[] = ",10";
15684 char lines_1[] = ",20";
15685 char lines_2[] = ",";
15693 suppress_error = 0;
15694 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15701 suppress_error = 0;
15702 r = guestfs_list_partitions (g);
15706 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15711 char expected[] = "/dev/sda1";
15713 if (strcmp (r[0], expected) != 0) {
15714 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15719 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15724 char expected[] = "/dev/sda2";
15726 if (strcmp (r[1], expected) != 0) {
15727 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15732 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15737 char expected[] = "/dev/sda3";
15739 if (strcmp (r[2], expected) != 0) {
15740 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15744 if (r[3] != NULL) {
15745 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
15749 for (i = 0; r[i] != NULL; ++i)
15756 static int test_list_devices_0_skip (void)
15760 str = getenv ("SKIP_TEST_LIST_DEVICES_0");
15761 if (str && strcmp (str, "1") == 0) return 1;
15762 str = getenv ("SKIP_TEST_LIST_DEVICES");
15763 if (str && strcmp (str, "1") == 0) return 1;
15767 static int test_list_devices_0 (void)
15769 if (test_list_devices_0_skip ()) {
15770 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_devices_0");
15774 /* InitNone|InitEmpty for test_list_devices_0 */
15776 char device[] = "/dev/sda";
15778 suppress_error = 0;
15779 r = guestfs_blockdev_setrw (g, device);
15785 suppress_error = 0;
15786 r = guestfs_umount_all (g);
15792 suppress_error = 0;
15793 r = guestfs_lvm_remove_all (g);
15797 /* TestOutputListOfDevices for list_devices (0) */
15801 suppress_error = 0;
15802 r = guestfs_list_devices (g);
15806 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15811 char expected[] = "/dev/sda";
15813 if (strcmp (r[0], expected) != 0) {
15814 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15819 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15824 char expected[] = "/dev/sdb";
15826 if (strcmp (r[1], expected) != 0) {
15827 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15832 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15837 char expected[] = "/dev/sdc";
15839 if (strcmp (r[2], expected) != 0) {
15840 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15845 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15850 char expected[] = "/dev/sdd";
15852 if (strcmp (r[3], expected) != 0) {
15853 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
15857 if (r[4] != NULL) {
15858 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
15862 for (i = 0; r[i] != NULL; ++i)
15869 static int test_ls_0_skip (void)
15873 str = getenv ("SKIP_TEST_LS_0");
15874 if (str && strcmp (str, "1") == 0) return 1;
15875 str = getenv ("SKIP_TEST_LS");
15876 if (str && strcmp (str, "1") == 0) return 1;
15880 static int test_ls_0 (void)
15882 if (test_ls_0_skip ()) {
15883 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ls_0");
15887 /* InitBasicFS for test_ls_0: create ext2 on /dev/sda1 */
15889 char device[] = "/dev/sda";
15891 suppress_error = 0;
15892 r = guestfs_blockdev_setrw (g, device);
15898 suppress_error = 0;
15899 r = guestfs_umount_all (g);
15905 suppress_error = 0;
15906 r = guestfs_lvm_remove_all (g);
15911 char device[] = "/dev/sda";
15912 char lines_0[] = ",";
15918 suppress_error = 0;
15919 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15924 char fstype[] = "ext2";
15925 char device[] = "/dev/sda1";
15927 suppress_error = 0;
15928 r = guestfs_mkfs (g, fstype, device);
15933 char device[] = "/dev/sda1";
15934 char mountpoint[] = "/";
15936 suppress_error = 0;
15937 r = guestfs_mount (g, device, mountpoint);
15941 /* TestOutputList for ls (0) */
15943 char path[] = "/new";
15945 suppress_error = 0;
15946 r = guestfs_touch (g, path);
15951 char path[] = "/newer";
15953 suppress_error = 0;
15954 r = guestfs_touch (g, path);
15959 char path[] = "/newest";
15961 suppress_error = 0;
15962 r = guestfs_touch (g, path);
15967 char directory[] = "/";
15970 suppress_error = 0;
15971 r = guestfs_ls (g, directory);
15975 fprintf (stderr, "test_ls_0: short list returned from command\n");
15980 char expected[] = "lost+found";
15981 if (strcmp (r[0], expected) != 0) {
15982 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15987 fprintf (stderr, "test_ls_0: short list returned from command\n");
15992 char expected[] = "new";
15993 if (strcmp (r[1], expected) != 0) {
15994 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15999 fprintf (stderr, "test_ls_0: short list returned from command\n");
16004 char expected[] = "newer";
16005 if (strcmp (r[2], expected) != 0) {
16006 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
16011 fprintf (stderr, "test_ls_0: short list returned from command\n");
16016 char expected[] = "newest";
16017 if (strcmp (r[3], expected) != 0) {
16018 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
16022 if (r[4] != NULL) {
16023 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
16027 for (i = 0; r[i] != NULL; ++i)
16034 static int test_cat_0_skip (void)
16038 str = getenv ("SKIP_TEST_CAT_0");
16039 if (str && strcmp (str, "1") == 0) return 1;
16040 str = getenv ("SKIP_TEST_CAT");
16041 if (str && strcmp (str, "1") == 0) return 1;
16045 static int test_cat_0 (void)
16047 if (test_cat_0_skip ()) {
16048 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cat_0");
16052 /* InitBasicFS for test_cat_0: create ext2 on /dev/sda1 */
16054 char device[] = "/dev/sda";
16056 suppress_error = 0;
16057 r = guestfs_blockdev_setrw (g, device);
16063 suppress_error = 0;
16064 r = guestfs_umount_all (g);
16070 suppress_error = 0;
16071 r = guestfs_lvm_remove_all (g);
16076 char device[] = "/dev/sda";
16077 char lines_0[] = ",";
16083 suppress_error = 0;
16084 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
16089 char fstype[] = "ext2";
16090 char device[] = "/dev/sda1";
16092 suppress_error = 0;
16093 r = guestfs_mkfs (g, fstype, device);
16098 char device[] = "/dev/sda1";
16099 char mountpoint[] = "/";
16101 suppress_error = 0;
16102 r = guestfs_mount (g, device, mountpoint);
16106 /* TestOutput for cat (0) */
16107 char expected[] = "new file contents";
16109 char path[] = "/new";
16110 char content[] = "new file contents";
16112 suppress_error = 0;
16113 r = guestfs_write_file (g, path, content, 0);
16118 char path[] = "/new";
16120 suppress_error = 0;
16121 r = guestfs_cat (g, path);
16124 if (strcmp (r, expected) != 0) {
16125 fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
16133 static int test_touch_0_skip (void)
16137 str = getenv ("SKIP_TEST_TOUCH_0");
16138 if (str && strcmp (str, "1") == 0) return 1;
16139 str = getenv ("SKIP_TEST_TOUCH");
16140 if (str && strcmp (str, "1") == 0) return 1;
16144 static int test_touch_0 (void)
16146 if (test_touch_0_skip ()) {
16147 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_touch_0");
16151 /* InitBasicFS for test_touch_0: create ext2 on /dev/sda1 */
16153 char device[] = "/dev/sda";
16155 suppress_error = 0;
16156 r = guestfs_blockdev_setrw (g, device);
16162 suppress_error = 0;
16163 r = guestfs_umount_all (g);
16169 suppress_error = 0;
16170 r = guestfs_lvm_remove_all (g);
16175 char device[] = "/dev/sda";
16176 char lines_0[] = ",";
16182 suppress_error = 0;
16183 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
16188 char fstype[] = "ext2";
16189 char device[] = "/dev/sda1";
16191 suppress_error = 0;
16192 r = guestfs_mkfs (g, fstype, device);
16197 char device[] = "/dev/sda1";
16198 char mountpoint[] = "/";
16200 suppress_error = 0;
16201 r = guestfs_mount (g, device, mountpoint);
16205 /* TestOutputTrue for touch (0) */
16207 char path[] = "/new";
16209 suppress_error = 0;
16210 r = guestfs_touch (g, path);
16215 char path[] = "/new";
16217 suppress_error = 0;
16218 r = guestfs_exists (g, path);
16222 fprintf (stderr, "test_touch_0: expected true, got false\n");
16229 static int test_sync_0_skip (void)
16233 str = getenv ("SKIP_TEST_SYNC_0");
16234 if (str && strcmp (str, "1") == 0) return 1;
16235 str = getenv ("SKIP_TEST_SYNC");
16236 if (str && strcmp (str, "1") == 0) return 1;
16240 static int test_sync_0 (void)
16242 if (test_sync_0_skip ()) {
16243 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_sync_0");
16247 /* InitNone|InitEmpty for test_sync_0 */
16249 char device[] = "/dev/sda";
16251 suppress_error = 0;
16252 r = guestfs_blockdev_setrw (g, device);
16258 suppress_error = 0;
16259 r = guestfs_umount_all (g);
16265 suppress_error = 0;
16266 r = guestfs_lvm_remove_all (g);
16270 /* TestRun for sync (0) */
16273 suppress_error = 0;
16274 r = guestfs_sync (g);
16281 static int test_mount_0_skip (void)
16285 str = getenv ("SKIP_TEST_MOUNT_0");
16286 if (str && strcmp (str, "1") == 0) return 1;
16287 str = getenv ("SKIP_TEST_MOUNT");
16288 if (str && strcmp (str, "1") == 0) return 1;
16292 static int test_mount_0 (void)
16294 if (test_mount_0_skip ()) {
16295 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_0");
16299 /* InitNone|InitEmpty for test_mount_0 */
16301 char device[] = "/dev/sda";
16303 suppress_error = 0;
16304 r = guestfs_blockdev_setrw (g, device);
16310 suppress_error = 0;
16311 r = guestfs_umount_all (g);
16317 suppress_error = 0;
16318 r = guestfs_lvm_remove_all (g);
16322 /* TestOutput for mount (0) */
16323 char expected[] = "new file contents";
16325 char device[] = "/dev/sda";
16326 char lines_0[] = ",";
16332 suppress_error = 0;
16333 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
16338 char fstype[] = "ext2";
16339 char device[] = "/dev/sda1";
16341 suppress_error = 0;
16342 r = guestfs_mkfs (g, fstype, device);
16347 char device[] = "/dev/sda1";
16348 char mountpoint[] = "/";
16350 suppress_error = 0;
16351 r = guestfs_mount (g, device, mountpoint);
16356 char path[] = "/new";
16357 char content[] = "new file contents";
16359 suppress_error = 0;
16360 r = guestfs_write_file (g, path, content, 0);
16365 char path[] = "/new";
16367 suppress_error = 0;
16368 r = guestfs_cat (g, path);
16371 if (strcmp (r, expected) != 0) {
16372 fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
16380 int main (int argc, char *argv[])
16384 const char *filename;
16386 int nr_tests, test_num = 0;
16388 no_test_warnings ();
16390 g = guestfs_create ();
16392 printf ("guestfs_create FAILED\n");
16396 guestfs_set_error_handler (g, print_error, NULL);
16398 guestfs_set_path (g, "../appliance");
16400 filename = "test1.img";
16401 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16406 if (lseek (fd, 524288000, SEEK_SET) == -1) {
16412 if (write (fd, &c, 1) == -1) {
16418 if (close (fd) == -1) {
16423 if (guestfs_add_drive (g, filename) == -1) {
16424 printf ("guestfs_add_drive %s FAILED\n", filename);
16428 filename = "test2.img";
16429 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16434 if (lseek (fd, 52428800, SEEK_SET) == -1) {
16440 if (write (fd, &c, 1) == -1) {
16446 if (close (fd) == -1) {
16451 if (guestfs_add_drive (g, filename) == -1) {
16452 printf ("guestfs_add_drive %s FAILED\n", filename);
16456 filename = "test3.img";
16457 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16462 if (lseek (fd, 10485760, SEEK_SET) == -1) {
16468 if (write (fd, &c, 1) == -1) {
16474 if (close (fd) == -1) {
16479 if (guestfs_add_drive (g, filename) == -1) {
16480 printf ("guestfs_add_drive %s FAILED\n", filename);
16484 if (guestfs_add_drive_ro (g, "../images/test.sqsh") == -1) {
16485 printf ("guestfs_add_drive_ro ../images/test.sqsh FAILED\n");
16489 if (guestfs_launch (g) == -1) {
16490 printf ("guestfs_launch FAILED\n");
16494 /* Set a timeout in case qemu hangs during launch (RHBZ#505329). */
16497 if (guestfs_wait_ready (g) == -1) {
16498 printf ("guestfs_wait_ready FAILED\n");
16502 /* Cancel previous alarm. */
16508 printf ("%3d/%3d test_mkdtemp_0\n", test_num, nr_tests);
16509 if (test_mkdtemp_0 () == -1) {
16510 printf ("test_mkdtemp_0 FAILED\n");
16514 printf ("%3d/%3d test_scrub_file_0\n", test_num, nr_tests);
16515 if (test_scrub_file_0 () == -1) {
16516 printf ("test_scrub_file_0 FAILED\n");
16520 printf ("%3d/%3d test_scrub_device_0\n", test_num, nr_tests);
16521 if (test_scrub_device_0 () == -1) {
16522 printf ("test_scrub_device_0 FAILED\n");
16526 printf ("%3d/%3d test_glob_expand_0\n", test_num, nr_tests);
16527 if (test_glob_expand_0 () == -1) {
16528 printf ("test_glob_expand_0 FAILED\n");
16532 printf ("%3d/%3d test_glob_expand_1\n", test_num, nr_tests);
16533 if (test_glob_expand_1 () == -1) {
16534 printf ("test_glob_expand_1 FAILED\n");
16538 printf ("%3d/%3d test_glob_expand_2\n", test_num, nr_tests);
16539 if (test_glob_expand_2 () == -1) {
16540 printf ("test_glob_expand_2 FAILED\n");
16544 printf ("%3d/%3d test_ntfs_3g_probe_0\n", test_num, nr_tests);
16545 if (test_ntfs_3g_probe_0 () == -1) {
16546 printf ("test_ntfs_3g_probe_0 FAILED\n");
16550 printf ("%3d/%3d test_ntfs_3g_probe_1\n", test_num, nr_tests);
16551 if (test_ntfs_3g_probe_1 () == -1) {
16552 printf ("test_ntfs_3g_probe_1 FAILED\n");
16556 printf ("%3d/%3d test_sleep_0\n", test_num, nr_tests);
16557 if (test_sleep_0 () == -1) {
16558 printf ("test_sleep_0 FAILED\n");
16562 printf ("%3d/%3d test_find_0\n", test_num, nr_tests);
16563 if (test_find_0 () == -1) {
16564 printf ("test_find_0 FAILED\n");
16568 printf ("%3d/%3d test_find_1\n", test_num, nr_tests);
16569 if (test_find_1 () == -1) {
16570 printf ("test_find_1 FAILED\n");
16574 printf ("%3d/%3d test_find_2\n", test_num, nr_tests);
16575 if (test_find_2 () == -1) {
16576 printf ("test_find_2 FAILED\n");
16580 printf ("%3d/%3d test_lvresize_0\n", test_num, nr_tests);
16581 if (test_lvresize_0 () == -1) {
16582 printf ("test_lvresize_0 FAILED\n");
16586 printf ("%3d/%3d test_zerofree_0\n", test_num, nr_tests);
16587 if (test_zerofree_0 () == -1) {
16588 printf ("test_zerofree_0 FAILED\n");
16592 printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
16593 if (test_hexdump_0 () == -1) {
16594 printf ("test_hexdump_0 FAILED\n");
16598 printf ("%3d/%3d test_hexdump_1\n", test_num, nr_tests);
16599 if (test_hexdump_1 () == -1) {
16600 printf ("test_hexdump_1 FAILED\n");
16604 printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
16605 if (test_strings_e_0 () == -1) {
16606 printf ("test_strings_e_0 FAILED\n");
16610 printf ("%3d/%3d test_strings_e_1\n", test_num, nr_tests);
16611 if (test_strings_e_1 () == -1) {
16612 printf ("test_strings_e_1 FAILED\n");
16616 printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
16617 if (test_strings_0 () == -1) {
16618 printf ("test_strings_0 FAILED\n");
16622 printf ("%3d/%3d test_strings_1\n", test_num, nr_tests);
16623 if (test_strings_1 () == -1) {
16624 printf ("test_strings_1 FAILED\n");
16628 printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
16629 if (test_equal_0 () == -1) {
16630 printf ("test_equal_0 FAILED\n");
16634 printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
16635 if (test_equal_1 () == -1) {
16636 printf ("test_equal_1 FAILED\n");
16640 printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
16641 if (test_equal_2 () == -1) {
16642 printf ("test_equal_2 FAILED\n");
16646 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
16647 if (test_ping_daemon_0 () == -1) {
16648 printf ("test_ping_daemon_0 FAILED\n");
16652 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
16653 if (test_dmesg_0 () == -1) {
16654 printf ("test_dmesg_0 FAILED\n");
16658 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
16659 if (test_drop_caches_0 () == -1) {
16660 printf ("test_drop_caches_0 FAILED\n");
16664 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
16665 if (test_mv_0 () == -1) {
16666 printf ("test_mv_0 FAILED\n");
16670 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
16671 if (test_mv_1 () == -1) {
16672 printf ("test_mv_1 FAILED\n");
16676 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
16677 if (test_cp_a_0 () == -1) {
16678 printf ("test_cp_a_0 FAILED\n");
16682 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
16683 if (test_cp_0 () == -1) {
16684 printf ("test_cp_0 FAILED\n");
16688 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
16689 if (test_cp_1 () == -1) {
16690 printf ("test_cp_1 FAILED\n");
16694 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
16695 if (test_cp_2 () == -1) {
16696 printf ("test_cp_2 FAILED\n");
16700 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
16701 if (test_grub_install_0 () == -1) {
16702 printf ("test_grub_install_0 FAILED\n");
16706 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
16707 if (test_zero_0 () == -1) {
16708 printf ("test_zero_0 FAILED\n");
16712 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
16713 if (test_fsck_0 () == -1) {
16714 printf ("test_fsck_0 FAILED\n");
16718 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
16719 if (test_fsck_1 () == -1) {
16720 printf ("test_fsck_1 FAILED\n");
16724 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
16725 if (test_set_e2uuid_0 () == -1) {
16726 printf ("test_set_e2uuid_0 FAILED\n");
16730 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
16731 if (test_set_e2uuid_1 () == -1) {
16732 printf ("test_set_e2uuid_1 FAILED\n");
16736 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
16737 if (test_set_e2uuid_2 () == -1) {
16738 printf ("test_set_e2uuid_2 FAILED\n");
16742 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
16743 if (test_set_e2uuid_3 () == -1) {
16744 printf ("test_set_e2uuid_3 FAILED\n");
16748 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
16749 if (test_set_e2label_0 () == -1) {
16750 printf ("test_set_e2label_0 FAILED\n");
16754 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
16755 if (test_pvremove_0 () == -1) {
16756 printf ("test_pvremove_0 FAILED\n");
16760 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
16761 if (test_pvremove_1 () == -1) {
16762 printf ("test_pvremove_1 FAILED\n");
16766 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
16767 if (test_pvremove_2 () == -1) {
16768 printf ("test_pvremove_2 FAILED\n");
16772 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
16773 if (test_vgremove_0 () == -1) {
16774 printf ("test_vgremove_0 FAILED\n");
16778 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
16779 if (test_vgremove_1 () == -1) {
16780 printf ("test_vgremove_1 FAILED\n");
16784 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
16785 if (test_lvremove_0 () == -1) {
16786 printf ("test_lvremove_0 FAILED\n");
16790 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
16791 if (test_lvremove_1 () == -1) {
16792 printf ("test_lvremove_1 FAILED\n");
16796 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
16797 if (test_lvremove_2 () == -1) {
16798 printf ("test_lvremove_2 FAILED\n");
16802 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
16803 if (test_mount_ro_0 () == -1) {
16804 printf ("test_mount_ro_0 FAILED\n");
16808 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
16809 if (test_mount_ro_1 () == -1) {
16810 printf ("test_mount_ro_1 FAILED\n");
16814 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
16815 if (test_tgz_in_0 () == -1) {
16816 printf ("test_tgz_in_0 FAILED\n");
16820 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
16821 if (test_tar_in_0 () == -1) {
16822 printf ("test_tar_in_0 FAILED\n");
16826 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
16827 if (test_checksum_0 () == -1) {
16828 printf ("test_checksum_0 FAILED\n");
16832 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
16833 if (test_checksum_1 () == -1) {
16834 printf ("test_checksum_1 FAILED\n");
16838 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
16839 if (test_checksum_2 () == -1) {
16840 printf ("test_checksum_2 FAILED\n");
16844 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
16845 if (test_checksum_3 () == -1) {
16846 printf ("test_checksum_3 FAILED\n");
16850 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
16851 if (test_checksum_4 () == -1) {
16852 printf ("test_checksum_4 FAILED\n");
16856 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
16857 if (test_checksum_5 () == -1) {
16858 printf ("test_checksum_5 FAILED\n");
16862 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
16863 if (test_checksum_6 () == -1) {
16864 printf ("test_checksum_6 FAILED\n");
16868 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
16869 if (test_checksum_7 () == -1) {
16870 printf ("test_checksum_7 FAILED\n");
16874 printf ("%3d/%3d test_checksum_8\n", test_num, nr_tests);
16875 if (test_checksum_8 () == -1) {
16876 printf ("test_checksum_8 FAILED\n");
16880 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
16881 if (test_download_0 () == -1) {
16882 printf ("test_download_0 FAILED\n");
16886 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
16887 if (test_upload_0 () == -1) {
16888 printf ("test_upload_0 FAILED\n");
16892 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
16893 if (test_blockdev_rereadpt_0 () == -1) {
16894 printf ("test_blockdev_rereadpt_0 FAILED\n");
16898 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
16899 if (test_blockdev_flushbufs_0 () == -1) {
16900 printf ("test_blockdev_flushbufs_0 FAILED\n");
16904 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
16905 if (test_blockdev_getsize64_0 () == -1) {
16906 printf ("test_blockdev_getsize64_0 FAILED\n");
16910 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
16911 if (test_blockdev_getsz_0 () == -1) {
16912 printf ("test_blockdev_getsz_0 FAILED\n");
16916 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
16917 if (test_blockdev_getbsz_0 () == -1) {
16918 printf ("test_blockdev_getbsz_0 FAILED\n");
16922 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
16923 if (test_blockdev_getss_0 () == -1) {
16924 printf ("test_blockdev_getss_0 FAILED\n");
16928 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
16929 if (test_blockdev_getro_0 () == -1) {
16930 printf ("test_blockdev_getro_0 FAILED\n");
16934 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
16935 if (test_blockdev_setrw_0 () == -1) {
16936 printf ("test_blockdev_setrw_0 FAILED\n");
16940 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
16941 if (test_blockdev_setro_0 () == -1) {
16942 printf ("test_blockdev_setro_0 FAILED\n");
16946 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
16947 if (test_statvfs_0 () == -1) {
16948 printf ("test_statvfs_0 FAILED\n");
16952 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
16953 if (test_lstat_0 () == -1) {
16954 printf ("test_lstat_0 FAILED\n");
16958 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
16959 if (test_stat_0 () == -1) {
16960 printf ("test_stat_0 FAILED\n");
16964 printf ("%3d/%3d test_command_lines_0\n", test_num, nr_tests);
16965 if (test_command_lines_0 () == -1) {
16966 printf ("test_command_lines_0 FAILED\n");
16970 printf ("%3d/%3d test_command_lines_1\n", test_num, nr_tests);
16971 if (test_command_lines_1 () == -1) {
16972 printf ("test_command_lines_1 FAILED\n");
16976 printf ("%3d/%3d test_command_lines_2\n", test_num, nr_tests);
16977 if (test_command_lines_2 () == -1) {
16978 printf ("test_command_lines_2 FAILED\n");
16982 printf ("%3d/%3d test_command_lines_3\n", test_num, nr_tests);
16983 if (test_command_lines_3 () == -1) {
16984 printf ("test_command_lines_3 FAILED\n");
16988 printf ("%3d/%3d test_command_lines_4\n", test_num, nr_tests);
16989 if (test_command_lines_4 () == -1) {
16990 printf ("test_command_lines_4 FAILED\n");
16994 printf ("%3d/%3d test_command_lines_5\n", test_num, nr_tests);
16995 if (test_command_lines_5 () == -1) {
16996 printf ("test_command_lines_5 FAILED\n");
17000 printf ("%3d/%3d test_command_lines_6\n", test_num, nr_tests);
17001 if (test_command_lines_6 () == -1) {
17002 printf ("test_command_lines_6 FAILED\n");
17006 printf ("%3d/%3d test_command_lines_7\n", test_num, nr_tests);
17007 if (test_command_lines_7 () == -1) {
17008 printf ("test_command_lines_7 FAILED\n");
17012 printf ("%3d/%3d test_command_lines_8\n", test_num, nr_tests);
17013 if (test_command_lines_8 () == -1) {
17014 printf ("test_command_lines_8 FAILED\n");
17018 printf ("%3d/%3d test_command_lines_9\n", test_num, nr_tests);
17019 if (test_command_lines_9 () == -1) {
17020 printf ("test_command_lines_9 FAILED\n");
17024 printf ("%3d/%3d test_command_lines_10\n", test_num, nr_tests);
17025 if (test_command_lines_10 () == -1) {
17026 printf ("test_command_lines_10 FAILED\n");
17030 printf ("%3d/%3d test_command_0\n", test_num, nr_tests);
17031 if (test_command_0 () == -1) {
17032 printf ("test_command_0 FAILED\n");
17036 printf ("%3d/%3d test_command_1\n", test_num, nr_tests);
17037 if (test_command_1 () == -1) {
17038 printf ("test_command_1 FAILED\n");
17042 printf ("%3d/%3d test_command_2\n", test_num, nr_tests);
17043 if (test_command_2 () == -1) {
17044 printf ("test_command_2 FAILED\n");
17048 printf ("%3d/%3d test_command_3\n", test_num, nr_tests);
17049 if (test_command_3 () == -1) {
17050 printf ("test_command_3 FAILED\n");
17054 printf ("%3d/%3d test_command_4\n", test_num, nr_tests);
17055 if (test_command_4 () == -1) {
17056 printf ("test_command_4 FAILED\n");
17060 printf ("%3d/%3d test_command_5\n", test_num, nr_tests);
17061 if (test_command_5 () == -1) {
17062 printf ("test_command_5 FAILED\n");
17066 printf ("%3d/%3d test_command_6\n", test_num, nr_tests);
17067 if (test_command_6 () == -1) {
17068 printf ("test_command_6 FAILED\n");
17072 printf ("%3d/%3d test_command_7\n", test_num, nr_tests);
17073 if (test_command_7 () == -1) {
17074 printf ("test_command_7 FAILED\n");
17078 printf ("%3d/%3d test_command_8\n", test_num, nr_tests);
17079 if (test_command_8 () == -1) {
17080 printf ("test_command_8 FAILED\n");
17084 printf ("%3d/%3d test_command_9\n", test_num, nr_tests);
17085 if (test_command_9 () == -1) {
17086 printf ("test_command_9 FAILED\n");
17090 printf ("%3d/%3d test_command_10\n", test_num, nr_tests);
17091 if (test_command_10 () == -1) {
17092 printf ("test_command_10 FAILED\n");
17096 printf ("%3d/%3d test_command_11\n", test_num, nr_tests);
17097 if (test_command_11 () == -1) {
17098 printf ("test_command_11 FAILED\n");
17102 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
17103 if (test_file_0 () == -1) {
17104 printf ("test_file_0 FAILED\n");
17108 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
17109 if (test_file_1 () == -1) {
17110 printf ("test_file_1 FAILED\n");
17114 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
17115 if (test_file_2 () == -1) {
17116 printf ("test_file_2 FAILED\n");
17120 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
17121 if (test_umount_all_0 () == -1) {
17122 printf ("test_umount_all_0 FAILED\n");
17126 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
17127 if (test_umount_all_1 () == -1) {
17128 printf ("test_umount_all_1 FAILED\n");
17132 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
17133 if (test_mounts_0 () == -1) {
17134 printf ("test_mounts_0 FAILED\n");
17138 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
17139 if (test_umount_0 () == -1) {
17140 printf ("test_umount_0 FAILED\n");
17144 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
17145 if (test_umount_1 () == -1) {
17146 printf ("test_umount_1 FAILED\n");
17150 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
17151 if (test_write_file_0 () == -1) {
17152 printf ("test_write_file_0 FAILED\n");
17156 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
17157 if (test_write_file_1 () == -1) {
17158 printf ("test_write_file_1 FAILED\n");
17162 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
17163 if (test_write_file_2 () == -1) {
17164 printf ("test_write_file_2 FAILED\n");
17168 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
17169 if (test_write_file_3 () == -1) {
17170 printf ("test_write_file_3 FAILED\n");
17174 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
17175 if (test_write_file_4 () == -1) {
17176 printf ("test_write_file_4 FAILED\n");
17180 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
17181 if (test_write_file_5 () == -1) {
17182 printf ("test_write_file_5 FAILED\n");
17186 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
17187 if (test_mkfs_0 () == -1) {
17188 printf ("test_mkfs_0 FAILED\n");
17192 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
17193 if (test_lvcreate_0 () == -1) {
17194 printf ("test_lvcreate_0 FAILED\n");
17198 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
17199 if (test_vgcreate_0 () == -1) {
17200 printf ("test_vgcreate_0 FAILED\n");
17204 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
17205 if (test_pvcreate_0 () == -1) {
17206 printf ("test_pvcreate_0 FAILED\n");
17210 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
17211 if (test_is_dir_0 () == -1) {
17212 printf ("test_is_dir_0 FAILED\n");
17216 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
17217 if (test_is_dir_1 () == -1) {
17218 printf ("test_is_dir_1 FAILED\n");
17222 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
17223 if (test_is_file_0 () == -1) {
17224 printf ("test_is_file_0 FAILED\n");
17228 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
17229 if (test_is_file_1 () == -1) {
17230 printf ("test_is_file_1 FAILED\n");
17234 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
17235 if (test_exists_0 () == -1) {
17236 printf ("test_exists_0 FAILED\n");
17240 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
17241 if (test_exists_1 () == -1) {
17242 printf ("test_exists_1 FAILED\n");
17246 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
17247 if (test_mkdir_p_0 () == -1) {
17248 printf ("test_mkdir_p_0 FAILED\n");
17252 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
17253 if (test_mkdir_p_1 () == -1) {
17254 printf ("test_mkdir_p_1 FAILED\n");
17258 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
17259 if (test_mkdir_p_2 () == -1) {
17260 printf ("test_mkdir_p_2 FAILED\n");
17264 printf ("%3d/%3d test_mkdir_p_3\n", test_num, nr_tests);
17265 if (test_mkdir_p_3 () == -1) {
17266 printf ("test_mkdir_p_3 FAILED\n");
17270 printf ("%3d/%3d test_mkdir_p_4\n", test_num, nr_tests);
17271 if (test_mkdir_p_4 () == -1) {
17272 printf ("test_mkdir_p_4 FAILED\n");
17276 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
17277 if (test_mkdir_0 () == -1) {
17278 printf ("test_mkdir_0 FAILED\n");
17282 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
17283 if (test_mkdir_1 () == -1) {
17284 printf ("test_mkdir_1 FAILED\n");
17288 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
17289 if (test_rm_rf_0 () == -1) {
17290 printf ("test_rm_rf_0 FAILED\n");
17294 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
17295 if (test_rmdir_0 () == -1) {
17296 printf ("test_rmdir_0 FAILED\n");
17300 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
17301 if (test_rmdir_1 () == -1) {
17302 printf ("test_rmdir_1 FAILED\n");
17306 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
17307 if (test_rmdir_2 () == -1) {
17308 printf ("test_rmdir_2 FAILED\n");
17312 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
17313 if (test_rm_0 () == -1) {
17314 printf ("test_rm_0 FAILED\n");
17318 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
17319 if (test_rm_1 () == -1) {
17320 printf ("test_rm_1 FAILED\n");
17324 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
17325 if (test_rm_2 () == -1) {
17326 printf ("test_rm_2 FAILED\n");
17330 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
17331 if (test_read_lines_0 () == -1) {
17332 printf ("test_read_lines_0 FAILED\n");
17336 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
17337 if (test_read_lines_1 () == -1) {
17338 printf ("test_read_lines_1 FAILED\n");
17342 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
17343 if (test_lvs_0 () == -1) {
17344 printf ("test_lvs_0 FAILED\n");
17348 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
17349 if (test_lvs_1 () == -1) {
17350 printf ("test_lvs_1 FAILED\n");
17354 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
17355 if (test_vgs_0 () == -1) {
17356 printf ("test_vgs_0 FAILED\n");
17360 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
17361 if (test_vgs_1 () == -1) {
17362 printf ("test_vgs_1 FAILED\n");
17366 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
17367 if (test_pvs_0 () == -1) {
17368 printf ("test_pvs_0 FAILED\n");
17372 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
17373 if (test_pvs_1 () == -1) {
17374 printf ("test_pvs_1 FAILED\n");
17378 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
17379 if (test_list_partitions_0 () == -1) {
17380 printf ("test_list_partitions_0 FAILED\n");
17384 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
17385 if (test_list_partitions_1 () == -1) {
17386 printf ("test_list_partitions_1 FAILED\n");
17390 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
17391 if (test_list_devices_0 () == -1) {
17392 printf ("test_list_devices_0 FAILED\n");
17396 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
17397 if (test_ls_0 () == -1) {
17398 printf ("test_ls_0 FAILED\n");
17402 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
17403 if (test_cat_0 () == -1) {
17404 printf ("test_cat_0 FAILED\n");
17408 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
17409 if (test_touch_0 () == -1) {
17410 printf ("test_touch_0 FAILED\n");
17414 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
17415 if (test_sync_0 () == -1) {
17416 printf ("test_sync_0 FAILED\n");
17420 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
17421 if (test_mount_0 () == -1) {
17422 printf ("test_mount_0 FAILED\n");
17427 unlink ("test1.img");
17428 unlink ("test2.img");
17429 unlink ("test3.img");
17432 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);