a8f1d73acae97b39876762134d22f5a0e52b962f
[libguestfs.git] / tests.c
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.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
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.
11  *
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.
16  *
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.
20  */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26 #include <sys/types.h>
27 #include <fcntl.h>
28
29 #include "guestfs.h"
30
31 static guestfs_h *g;
32 static int suppress_error = 0;
33
34 /* This will be 's' or 'h' depending on whether the guest kernel
35  * names IDE devices /dev/sd* or /dev/hd*.
36  */
37 static char devchar = 's';
38
39 static void print_error (guestfs_h *g, void *data, const char *msg)
40 {
41   if (!suppress_error)
42     fprintf (stderr, "%s\n", msg);
43 }
44
45 static void print_strings (char * const * const argv)
46 {
47   int argc;
48
49   for (argc = 0; argv[argc] != NULL; ++argc)
50     printf ("\t%s\n", argv[argc]);
51 }
52
53 /*
54 static void print_table (char * const * const argv)
55 {
56   int i;
57
58   for (i = 0; argv[i] != NULL; i += 2)
59     printf ("%s: %s\n", argv[i], argv[i+1]);
60 }
61 */
62
63 static void no_test_warnings (void)
64 {
65   fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
66   fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
67   fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
68   fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
69   fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
70   fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
71   fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
72   fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
73   fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
74   fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
75   fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
76   fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
77   fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
78   fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
79   fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
80   fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
81   fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
82   fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
83   fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
84   fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
85   fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
86   fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
87   fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
88   fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
89   fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
90   fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
91   fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
92   fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
93   fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
94   fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
95   fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
96   fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
97   fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
98   fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
99   fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
100   fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
101   fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
102   fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
103   fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
104   fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
105   fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
106   fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
107   fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
108   fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
109   fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
110   fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
111   fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
112   fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
113   fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
114   fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
115   fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
116   fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
117   fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
118   fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
119 }
120
121 static int test_hexdump_0 (void)
122 {
123   /* InitBasicFS for hexdump (0): create ext2 on /dev/sda1 */
124   {
125     char device[] = "/dev/sda";
126     device[5] = devchar;
127     int r;
128     suppress_error = 0;
129     r = guestfs_blockdev_setrw (g, device);
130     if (r == -1)
131       return -1;
132   }
133   {
134     int r;
135     suppress_error = 0;
136     r = guestfs_umount_all (g);
137     if (r == -1)
138       return -1;
139   }
140   {
141     int r;
142     suppress_error = 0;
143     r = guestfs_lvm_remove_all (g);
144     if (r == -1)
145       return -1;
146   }
147   {
148     char device[] = "/dev/sda";
149     device[5] = devchar;
150     char lines_0[] = ",";
151     char *lines[] = {
152       lines_0,
153       NULL
154     };
155     int r;
156     suppress_error = 0;
157     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
158     if (r == -1)
159       return -1;
160   }
161   {
162     char fstype[] = "ext2";
163     char device[] = "/dev/sda1";
164     device[5] = devchar;
165     int r;
166     suppress_error = 0;
167     r = guestfs_mkfs (g, fstype, device);
168     if (r == -1)
169       return -1;
170   }
171   {
172     char device[] = "/dev/sda1";
173     device[5] = devchar;
174     char mountpoint[] = "/";
175     int r;
176     suppress_error = 0;
177     r = guestfs_mount (g, device, mountpoint);
178     if (r == -1)
179       return -1;
180   }
181   /* TestOutput for hexdump (0) */
182   char expected[] = "00000000  68 65 6c 6c 6f 0a 77 6f  72 6c 64 0a              |hello.world.|\n0000000c\n";
183   {
184     char path[] = "/new";
185     char content[] = "hello\nworld\n";
186     int r;
187     suppress_error = 0;
188     r = guestfs_write_file (g, path, content, 12);
189     if (r == -1)
190       return -1;
191   }
192   {
193     char path[] = "/new";
194     char *r;
195     suppress_error = 0;
196     r = guestfs_hexdump (g, path);
197     if (r == NULL)
198       return -1;
199     if (strcmp (r, expected) != 0) {
200       fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
201       return -1;
202     }
203     free (r);
204   }
205   return 0;
206 }
207
208 static int test_strings_e_0 (void)
209 {
210   /* InitBasicFS for strings_e (0): create ext2 on /dev/sda1 */
211   {
212     char device[] = "/dev/sda";
213     device[5] = devchar;
214     int r;
215     suppress_error = 0;
216     r = guestfs_blockdev_setrw (g, device);
217     if (r == -1)
218       return -1;
219   }
220   {
221     int r;
222     suppress_error = 0;
223     r = guestfs_umount_all (g);
224     if (r == -1)
225       return -1;
226   }
227   {
228     int r;
229     suppress_error = 0;
230     r = guestfs_lvm_remove_all (g);
231     if (r == -1)
232       return -1;
233   }
234   {
235     char device[] = "/dev/sda";
236     device[5] = devchar;
237     char lines_0[] = ",";
238     char *lines[] = {
239       lines_0,
240       NULL
241     };
242     int r;
243     suppress_error = 0;
244     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
245     if (r == -1)
246       return -1;
247   }
248   {
249     char fstype[] = "ext2";
250     char device[] = "/dev/sda1";
251     device[5] = devchar;
252     int r;
253     suppress_error = 0;
254     r = guestfs_mkfs (g, fstype, device);
255     if (r == -1)
256       return -1;
257   }
258   {
259     char device[] = "/dev/sda1";
260     device[5] = devchar;
261     char mountpoint[] = "/";
262     int r;
263     suppress_error = 0;
264     r = guestfs_mount (g, device, mountpoint);
265     if (r == -1)
266       return -1;
267   }
268   /* TestOutputList for strings_e (0) */
269   {
270     char path[] = "/new";
271     char content[] = "hello\nworld\n";
272     int r;
273     suppress_error = 0;
274     r = guestfs_write_file (g, path, content, 0);
275     if (r == -1)
276       return -1;
277   }
278   {
279     char encoding[] = "b";
280     char path[] = "/new";
281     char **r;
282     int i;
283     suppress_error = 0;
284     r = guestfs_strings_e (g, encoding, path);
285     if (r == NULL)
286       return -1;
287     if (r[0] != NULL) {
288       fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
289       print_strings (r);
290       return -1;
291     }
292     for (i = 0; r[i] != NULL; ++i)
293       free (r[i]);
294     free (r);
295   }
296   return 0;
297 }
298
299 static int test_strings_0 (void)
300 {
301   /* InitBasicFS for strings (0): create ext2 on /dev/sda1 */
302   {
303     char device[] = "/dev/sda";
304     device[5] = devchar;
305     int r;
306     suppress_error = 0;
307     r = guestfs_blockdev_setrw (g, device);
308     if (r == -1)
309       return -1;
310   }
311   {
312     int r;
313     suppress_error = 0;
314     r = guestfs_umount_all (g);
315     if (r == -1)
316       return -1;
317   }
318   {
319     int r;
320     suppress_error = 0;
321     r = guestfs_lvm_remove_all (g);
322     if (r == -1)
323       return -1;
324   }
325   {
326     char device[] = "/dev/sda";
327     device[5] = devchar;
328     char lines_0[] = ",";
329     char *lines[] = {
330       lines_0,
331       NULL
332     };
333     int r;
334     suppress_error = 0;
335     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
336     if (r == -1)
337       return -1;
338   }
339   {
340     char fstype[] = "ext2";
341     char device[] = "/dev/sda1";
342     device[5] = devchar;
343     int r;
344     suppress_error = 0;
345     r = guestfs_mkfs (g, fstype, device);
346     if (r == -1)
347       return -1;
348   }
349   {
350     char device[] = "/dev/sda1";
351     device[5] = devchar;
352     char mountpoint[] = "/";
353     int r;
354     suppress_error = 0;
355     r = guestfs_mount (g, device, mountpoint);
356     if (r == -1)
357       return -1;
358   }
359   /* TestOutputList for strings (0) */
360   {
361     char path[] = "/new";
362     char content[] = "hello\nworld\n";
363     int r;
364     suppress_error = 0;
365     r = guestfs_write_file (g, path, content, 0);
366     if (r == -1)
367       return -1;
368   }
369   {
370     char path[] = "/new";
371     char **r;
372     int i;
373     suppress_error = 0;
374     r = guestfs_strings (g, path);
375     if (r == NULL)
376       return -1;
377     if (!r[0]) {
378       fprintf (stderr, "test_strings_0: short list returned from command\n");
379       print_strings (r);
380       return -1;
381     }
382     {
383       char expected[] = "hello";
384       if (strcmp (r[0], expected) != 0) {
385         fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
386         return -1;
387       }
388     }
389     if (!r[1]) {
390       fprintf (stderr, "test_strings_0: short list returned from command\n");
391       print_strings (r);
392       return -1;
393     }
394     {
395       char expected[] = "world";
396       if (strcmp (r[1], expected) != 0) {
397         fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
398         return -1;
399       }
400     }
401     if (r[2] != NULL) {
402       fprintf (stderr, "test_strings_0: extra elements returned from command\n");
403       print_strings (r);
404       return -1;
405     }
406     for (i = 0; r[i] != NULL; ++i)
407       free (r[i]);
408     free (r);
409   }
410   return 0;
411 }
412
413 static int test_equal_0 (void)
414 {
415   /* InitBasicFS for equal (0): create ext2 on /dev/sda1 */
416   {
417     char device[] = "/dev/sda";
418     device[5] = devchar;
419     int r;
420     suppress_error = 0;
421     r = guestfs_blockdev_setrw (g, device);
422     if (r == -1)
423       return -1;
424   }
425   {
426     int r;
427     suppress_error = 0;
428     r = guestfs_umount_all (g);
429     if (r == -1)
430       return -1;
431   }
432   {
433     int r;
434     suppress_error = 0;
435     r = guestfs_lvm_remove_all (g);
436     if (r == -1)
437       return -1;
438   }
439   {
440     char device[] = "/dev/sda";
441     device[5] = devchar;
442     char lines_0[] = ",";
443     char *lines[] = {
444       lines_0,
445       NULL
446     };
447     int r;
448     suppress_error = 0;
449     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
450     if (r == -1)
451       return -1;
452   }
453   {
454     char fstype[] = "ext2";
455     char device[] = "/dev/sda1";
456     device[5] = devchar;
457     int r;
458     suppress_error = 0;
459     r = guestfs_mkfs (g, fstype, device);
460     if (r == -1)
461       return -1;
462   }
463   {
464     char device[] = "/dev/sda1";
465     device[5] = devchar;
466     char mountpoint[] = "/";
467     int r;
468     suppress_error = 0;
469     r = guestfs_mount (g, device, mountpoint);
470     if (r == -1)
471       return -1;
472   }
473   /* TestOutputTrue for equal (0) */
474   {
475     char path[] = "/file1";
476     char content[] = "contents of a file";
477     int r;
478     suppress_error = 0;
479     r = guestfs_write_file (g, path, content, 0);
480     if (r == -1)
481       return -1;
482   }
483   {
484     char src[] = "/file1";
485     char dest[] = "/file2";
486     int r;
487     suppress_error = 0;
488     r = guestfs_cp (g, src, dest);
489     if (r == -1)
490       return -1;
491   }
492   {
493     char file1[] = "/file1";
494     char file2[] = "/file2";
495     int r;
496     suppress_error = 0;
497     r = guestfs_equal (g, file1, file2);
498     if (r == -1)
499       return -1;
500     if (!r) {
501       fprintf (stderr, "test_equal_0: expected true, got false\n");
502       return -1;
503     }
504   }
505   return 0;
506 }
507
508 static int test_equal_1 (void)
509 {
510   /* InitBasicFS for equal (1): create ext2 on /dev/sda1 */
511   {
512     char device[] = "/dev/sda";
513     device[5] = devchar;
514     int r;
515     suppress_error = 0;
516     r = guestfs_blockdev_setrw (g, device);
517     if (r == -1)
518       return -1;
519   }
520   {
521     int r;
522     suppress_error = 0;
523     r = guestfs_umount_all (g);
524     if (r == -1)
525       return -1;
526   }
527   {
528     int r;
529     suppress_error = 0;
530     r = guestfs_lvm_remove_all (g);
531     if (r == -1)
532       return -1;
533   }
534   {
535     char device[] = "/dev/sda";
536     device[5] = devchar;
537     char lines_0[] = ",";
538     char *lines[] = {
539       lines_0,
540       NULL
541     };
542     int r;
543     suppress_error = 0;
544     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
545     if (r == -1)
546       return -1;
547   }
548   {
549     char fstype[] = "ext2";
550     char device[] = "/dev/sda1";
551     device[5] = devchar;
552     int r;
553     suppress_error = 0;
554     r = guestfs_mkfs (g, fstype, device);
555     if (r == -1)
556       return -1;
557   }
558   {
559     char device[] = "/dev/sda1";
560     device[5] = devchar;
561     char mountpoint[] = "/";
562     int r;
563     suppress_error = 0;
564     r = guestfs_mount (g, device, mountpoint);
565     if (r == -1)
566       return -1;
567   }
568   /* TestOutputFalse for equal (1) */
569   {
570     char path[] = "/file1";
571     char content[] = "contents of a file";
572     int r;
573     suppress_error = 0;
574     r = guestfs_write_file (g, path, content, 0);
575     if (r == -1)
576       return -1;
577   }
578   {
579     char path[] = "/file2";
580     char content[] = "contents of another file";
581     int r;
582     suppress_error = 0;
583     r = guestfs_write_file (g, path, content, 0);
584     if (r == -1)
585       return -1;
586   }
587   {
588     char file1[] = "/file1";
589     char file2[] = "/file2";
590     int r;
591     suppress_error = 0;
592     r = guestfs_equal (g, file1, file2);
593     if (r == -1)
594       return -1;
595     if (r) {
596       fprintf (stderr, "test_equal_1: expected false, got true\n");
597       return -1;
598     }
599   }
600   return 0;
601 }
602
603 static int test_equal_2 (void)
604 {
605   /* InitBasicFS for equal (2): create ext2 on /dev/sda1 */
606   {
607     char device[] = "/dev/sda";
608     device[5] = devchar;
609     int r;
610     suppress_error = 0;
611     r = guestfs_blockdev_setrw (g, device);
612     if (r == -1)
613       return -1;
614   }
615   {
616     int r;
617     suppress_error = 0;
618     r = guestfs_umount_all (g);
619     if (r == -1)
620       return -1;
621   }
622   {
623     int r;
624     suppress_error = 0;
625     r = guestfs_lvm_remove_all (g);
626     if (r == -1)
627       return -1;
628   }
629   {
630     char device[] = "/dev/sda";
631     device[5] = devchar;
632     char lines_0[] = ",";
633     char *lines[] = {
634       lines_0,
635       NULL
636     };
637     int r;
638     suppress_error = 0;
639     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
640     if (r == -1)
641       return -1;
642   }
643   {
644     char fstype[] = "ext2";
645     char device[] = "/dev/sda1";
646     device[5] = devchar;
647     int r;
648     suppress_error = 0;
649     r = guestfs_mkfs (g, fstype, device);
650     if (r == -1)
651       return -1;
652   }
653   {
654     char device[] = "/dev/sda1";
655     device[5] = devchar;
656     char mountpoint[] = "/";
657     int r;
658     suppress_error = 0;
659     r = guestfs_mount (g, device, mountpoint);
660     if (r == -1)
661       return -1;
662   }
663   /* TestLastFail for equal (2) */
664   {
665     char file1[] = "/file1";
666     char file2[] = "/file2";
667     int r;
668     suppress_error = 1;
669     r = guestfs_equal (g, file1, file2);
670     if (r != -1)
671       return -1;
672   }
673   return 0;
674 }
675
676 static int test_ping_daemon_0 (void)
677 {
678   /* InitEmpty for ping_daemon (0) */
679   {
680     char device[] = "/dev/sda";
681     device[5] = devchar;
682     int r;
683     suppress_error = 0;
684     r = guestfs_blockdev_setrw (g, device);
685     if (r == -1)
686       return -1;
687   }
688   {
689     int r;
690     suppress_error = 0;
691     r = guestfs_umount_all (g);
692     if (r == -1)
693       return -1;
694   }
695   {
696     int r;
697     suppress_error = 0;
698     r = guestfs_lvm_remove_all (g);
699     if (r == -1)
700       return -1;
701   }
702   /* TestRun for ping_daemon (0) */
703   {
704     int r;
705     suppress_error = 0;
706     r = guestfs_ping_daemon (g);
707     if (r == -1)
708       return -1;
709   }
710   return 0;
711 }
712
713 static int test_dmesg_0 (void)
714 {
715   /* InitEmpty for dmesg (0) */
716   {
717     char device[] = "/dev/sda";
718     device[5] = devchar;
719     int r;
720     suppress_error = 0;
721     r = guestfs_blockdev_setrw (g, device);
722     if (r == -1)
723       return -1;
724   }
725   {
726     int r;
727     suppress_error = 0;
728     r = guestfs_umount_all (g);
729     if (r == -1)
730       return -1;
731   }
732   {
733     int r;
734     suppress_error = 0;
735     r = guestfs_lvm_remove_all (g);
736     if (r == -1)
737       return -1;
738   }
739   /* TestRun for dmesg (0) */
740   {
741     char *r;
742     suppress_error = 0;
743     r = guestfs_dmesg (g);
744     if (r == NULL)
745       return -1;
746     free (r);
747   }
748   return 0;
749 }
750
751 static int test_drop_caches_0 (void)
752 {
753   /* InitEmpty for drop_caches (0) */
754   {
755     char device[] = "/dev/sda";
756     device[5] = devchar;
757     int r;
758     suppress_error = 0;
759     r = guestfs_blockdev_setrw (g, device);
760     if (r == -1)
761       return -1;
762   }
763   {
764     int r;
765     suppress_error = 0;
766     r = guestfs_umount_all (g);
767     if (r == -1)
768       return -1;
769   }
770   {
771     int r;
772     suppress_error = 0;
773     r = guestfs_lvm_remove_all (g);
774     if (r == -1)
775       return -1;
776   }
777   /* TestRun for drop_caches (0) */
778   {
779     int r;
780     suppress_error = 0;
781     r = guestfs_drop_caches (g, 3);
782     if (r == -1)
783       return -1;
784   }
785   return 0;
786 }
787
788 static int test_mv_0 (void)
789 {
790   /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
791   {
792     char device[] = "/dev/sda";
793     device[5] = devchar;
794     int r;
795     suppress_error = 0;
796     r = guestfs_blockdev_setrw (g, device);
797     if (r == -1)
798       return -1;
799   }
800   {
801     int r;
802     suppress_error = 0;
803     r = guestfs_umount_all (g);
804     if (r == -1)
805       return -1;
806   }
807   {
808     int r;
809     suppress_error = 0;
810     r = guestfs_lvm_remove_all (g);
811     if (r == -1)
812       return -1;
813   }
814   {
815     char device[] = "/dev/sda";
816     device[5] = devchar;
817     char lines_0[] = ",";
818     char *lines[] = {
819       lines_0,
820       NULL
821     };
822     int r;
823     suppress_error = 0;
824     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
825     if (r == -1)
826       return -1;
827   }
828   {
829     char fstype[] = "ext2";
830     char device[] = "/dev/sda1";
831     device[5] = devchar;
832     int r;
833     suppress_error = 0;
834     r = guestfs_mkfs (g, fstype, device);
835     if (r == -1)
836       return -1;
837   }
838   {
839     char device[] = "/dev/sda1";
840     device[5] = devchar;
841     char mountpoint[] = "/";
842     int r;
843     suppress_error = 0;
844     r = guestfs_mount (g, device, mountpoint);
845     if (r == -1)
846       return -1;
847   }
848   /* TestOutput for mv (0) */
849   char expected[] = "file content";
850   {
851     char path[] = "/old";
852     char content[] = "file content";
853     int r;
854     suppress_error = 0;
855     r = guestfs_write_file (g, path, content, 0);
856     if (r == -1)
857       return -1;
858   }
859   {
860     char src[] = "/old";
861     char dest[] = "/new";
862     int r;
863     suppress_error = 0;
864     r = guestfs_mv (g, src, dest);
865     if (r == -1)
866       return -1;
867   }
868   {
869     char path[] = "/new";
870     char *r;
871     suppress_error = 0;
872     r = guestfs_cat (g, path);
873     if (r == NULL)
874       return -1;
875     if (strcmp (r, expected) != 0) {
876       fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
877       return -1;
878     }
879     free (r);
880   }
881   return 0;
882 }
883
884 static int test_mv_1 (void)
885 {
886   /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
887   {
888     char device[] = "/dev/sda";
889     device[5] = devchar;
890     int r;
891     suppress_error = 0;
892     r = guestfs_blockdev_setrw (g, device);
893     if (r == -1)
894       return -1;
895   }
896   {
897     int r;
898     suppress_error = 0;
899     r = guestfs_umount_all (g);
900     if (r == -1)
901       return -1;
902   }
903   {
904     int r;
905     suppress_error = 0;
906     r = guestfs_lvm_remove_all (g);
907     if (r == -1)
908       return -1;
909   }
910   {
911     char device[] = "/dev/sda";
912     device[5] = devchar;
913     char lines_0[] = ",";
914     char *lines[] = {
915       lines_0,
916       NULL
917     };
918     int r;
919     suppress_error = 0;
920     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
921     if (r == -1)
922       return -1;
923   }
924   {
925     char fstype[] = "ext2";
926     char device[] = "/dev/sda1";
927     device[5] = devchar;
928     int r;
929     suppress_error = 0;
930     r = guestfs_mkfs (g, fstype, device);
931     if (r == -1)
932       return -1;
933   }
934   {
935     char device[] = "/dev/sda1";
936     device[5] = devchar;
937     char mountpoint[] = "/";
938     int r;
939     suppress_error = 0;
940     r = guestfs_mount (g, device, mountpoint);
941     if (r == -1)
942       return -1;
943   }
944   /* TestOutputFalse for mv (1) */
945   {
946     char path[] = "/old";
947     char content[] = "file content";
948     int r;
949     suppress_error = 0;
950     r = guestfs_write_file (g, path, content, 0);
951     if (r == -1)
952       return -1;
953   }
954   {
955     char src[] = "/old";
956     char dest[] = "/new";
957     int r;
958     suppress_error = 0;
959     r = guestfs_mv (g, src, dest);
960     if (r == -1)
961       return -1;
962   }
963   {
964     char path[] = "/old";
965     int r;
966     suppress_error = 0;
967     r = guestfs_is_file (g, path);
968     if (r == -1)
969       return -1;
970     if (r) {
971       fprintf (stderr, "test_mv_1: expected false, got true\n");
972       return -1;
973     }
974   }
975   return 0;
976 }
977
978 static int test_cp_a_0 (void)
979 {
980   /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
981   {
982     char device[] = "/dev/sda";
983     device[5] = devchar;
984     int r;
985     suppress_error = 0;
986     r = guestfs_blockdev_setrw (g, device);
987     if (r == -1)
988       return -1;
989   }
990   {
991     int r;
992     suppress_error = 0;
993     r = guestfs_umount_all (g);
994     if (r == -1)
995       return -1;
996   }
997   {
998     int r;
999     suppress_error = 0;
1000     r = guestfs_lvm_remove_all (g);
1001     if (r == -1)
1002       return -1;
1003   }
1004   {
1005     char device[] = "/dev/sda";
1006     device[5] = devchar;
1007     char lines_0[] = ",";
1008     char *lines[] = {
1009       lines_0,
1010       NULL
1011     };
1012     int r;
1013     suppress_error = 0;
1014     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1015     if (r == -1)
1016       return -1;
1017   }
1018   {
1019     char fstype[] = "ext2";
1020     char device[] = "/dev/sda1";
1021     device[5] = devchar;
1022     int r;
1023     suppress_error = 0;
1024     r = guestfs_mkfs (g, fstype, device);
1025     if (r == -1)
1026       return -1;
1027   }
1028   {
1029     char device[] = "/dev/sda1";
1030     device[5] = devchar;
1031     char mountpoint[] = "/";
1032     int r;
1033     suppress_error = 0;
1034     r = guestfs_mount (g, device, mountpoint);
1035     if (r == -1)
1036       return -1;
1037   }
1038   /* TestOutput for cp_a (0) */
1039   char expected[] = "file content";
1040   {
1041     char path[] = "/olddir";
1042     int r;
1043     suppress_error = 0;
1044     r = guestfs_mkdir (g, path);
1045     if (r == -1)
1046       return -1;
1047   }
1048   {
1049     char path[] = "/newdir";
1050     int r;
1051     suppress_error = 0;
1052     r = guestfs_mkdir (g, path);
1053     if (r == -1)
1054       return -1;
1055   }
1056   {
1057     char path[] = "/olddir/file";
1058     char content[] = "file content";
1059     int r;
1060     suppress_error = 0;
1061     r = guestfs_write_file (g, path, content, 0);
1062     if (r == -1)
1063       return -1;
1064   }
1065   {
1066     char src[] = "/olddir";
1067     char dest[] = "/newdir";
1068     int r;
1069     suppress_error = 0;
1070     r = guestfs_cp_a (g, src, dest);
1071     if (r == -1)
1072       return -1;
1073   }
1074   {
1075     char path[] = "/newdir/olddir/file";
1076     char *r;
1077     suppress_error = 0;
1078     r = guestfs_cat (g, path);
1079     if (r == NULL)
1080       return -1;
1081     if (strcmp (r, expected) != 0) {
1082       fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
1083       return -1;
1084     }
1085     free (r);
1086   }
1087   return 0;
1088 }
1089
1090 static int test_cp_0 (void)
1091 {
1092   /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
1093   {
1094     char device[] = "/dev/sda";
1095     device[5] = devchar;
1096     int r;
1097     suppress_error = 0;
1098     r = guestfs_blockdev_setrw (g, device);
1099     if (r == -1)
1100       return -1;
1101   }
1102   {
1103     int r;
1104     suppress_error = 0;
1105     r = guestfs_umount_all (g);
1106     if (r == -1)
1107       return -1;
1108   }
1109   {
1110     int r;
1111     suppress_error = 0;
1112     r = guestfs_lvm_remove_all (g);
1113     if (r == -1)
1114       return -1;
1115   }
1116   {
1117     char device[] = "/dev/sda";
1118     device[5] = devchar;
1119     char lines_0[] = ",";
1120     char *lines[] = {
1121       lines_0,
1122       NULL
1123     };
1124     int r;
1125     suppress_error = 0;
1126     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1127     if (r == -1)
1128       return -1;
1129   }
1130   {
1131     char fstype[] = "ext2";
1132     char device[] = "/dev/sda1";
1133     device[5] = devchar;
1134     int r;
1135     suppress_error = 0;
1136     r = guestfs_mkfs (g, fstype, device);
1137     if (r == -1)
1138       return -1;
1139   }
1140   {
1141     char device[] = "/dev/sda1";
1142     device[5] = devchar;
1143     char mountpoint[] = "/";
1144     int r;
1145     suppress_error = 0;
1146     r = guestfs_mount (g, device, mountpoint);
1147     if (r == -1)
1148       return -1;
1149   }
1150   /* TestOutput for cp (0) */
1151   char expected[] = "file content";
1152   {
1153     char path[] = "/old";
1154     char content[] = "file content";
1155     int r;
1156     suppress_error = 0;
1157     r = guestfs_write_file (g, path, content, 0);
1158     if (r == -1)
1159       return -1;
1160   }
1161   {
1162     char src[] = "/old";
1163     char dest[] = "/new";
1164     int r;
1165     suppress_error = 0;
1166     r = guestfs_cp (g, src, dest);
1167     if (r == -1)
1168       return -1;
1169   }
1170   {
1171     char path[] = "/new";
1172     char *r;
1173     suppress_error = 0;
1174     r = guestfs_cat (g, path);
1175     if (r == NULL)
1176       return -1;
1177     if (strcmp (r, expected) != 0) {
1178       fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
1179       return -1;
1180     }
1181     free (r);
1182   }
1183   return 0;
1184 }
1185
1186 static int test_cp_1 (void)
1187 {
1188   /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
1189   {
1190     char device[] = "/dev/sda";
1191     device[5] = devchar;
1192     int r;
1193     suppress_error = 0;
1194     r = guestfs_blockdev_setrw (g, device);
1195     if (r == -1)
1196       return -1;
1197   }
1198   {
1199     int r;
1200     suppress_error = 0;
1201     r = guestfs_umount_all (g);
1202     if (r == -1)
1203       return -1;
1204   }
1205   {
1206     int r;
1207     suppress_error = 0;
1208     r = guestfs_lvm_remove_all (g);
1209     if (r == -1)
1210       return -1;
1211   }
1212   {
1213     char device[] = "/dev/sda";
1214     device[5] = devchar;
1215     char lines_0[] = ",";
1216     char *lines[] = {
1217       lines_0,
1218       NULL
1219     };
1220     int r;
1221     suppress_error = 0;
1222     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1223     if (r == -1)
1224       return -1;
1225   }
1226   {
1227     char fstype[] = "ext2";
1228     char device[] = "/dev/sda1";
1229     device[5] = devchar;
1230     int r;
1231     suppress_error = 0;
1232     r = guestfs_mkfs (g, fstype, device);
1233     if (r == -1)
1234       return -1;
1235   }
1236   {
1237     char device[] = "/dev/sda1";
1238     device[5] = devchar;
1239     char mountpoint[] = "/";
1240     int r;
1241     suppress_error = 0;
1242     r = guestfs_mount (g, device, mountpoint);
1243     if (r == -1)
1244       return -1;
1245   }
1246   /* TestOutputTrue for cp (1) */
1247   {
1248     char path[] = "/old";
1249     char content[] = "file content";
1250     int r;
1251     suppress_error = 0;
1252     r = guestfs_write_file (g, path, content, 0);
1253     if (r == -1)
1254       return -1;
1255   }
1256   {
1257     char src[] = "/old";
1258     char dest[] = "/new";
1259     int r;
1260     suppress_error = 0;
1261     r = guestfs_cp (g, src, dest);
1262     if (r == -1)
1263       return -1;
1264   }
1265   {
1266     char path[] = "/old";
1267     int r;
1268     suppress_error = 0;
1269     r = guestfs_is_file (g, path);
1270     if (r == -1)
1271       return -1;
1272     if (!r) {
1273       fprintf (stderr, "test_cp_1: expected true, got false\n");
1274       return -1;
1275     }
1276   }
1277   return 0;
1278 }
1279
1280 static int test_cp_2 (void)
1281 {
1282   /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
1283   {
1284     char device[] = "/dev/sda";
1285     device[5] = devchar;
1286     int r;
1287     suppress_error = 0;
1288     r = guestfs_blockdev_setrw (g, device);
1289     if (r == -1)
1290       return -1;
1291   }
1292   {
1293     int r;
1294     suppress_error = 0;
1295     r = guestfs_umount_all (g);
1296     if (r == -1)
1297       return -1;
1298   }
1299   {
1300     int r;
1301     suppress_error = 0;
1302     r = guestfs_lvm_remove_all (g);
1303     if (r == -1)
1304       return -1;
1305   }
1306   {
1307     char device[] = "/dev/sda";
1308     device[5] = devchar;
1309     char lines_0[] = ",";
1310     char *lines[] = {
1311       lines_0,
1312       NULL
1313     };
1314     int r;
1315     suppress_error = 0;
1316     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1317     if (r == -1)
1318       return -1;
1319   }
1320   {
1321     char fstype[] = "ext2";
1322     char device[] = "/dev/sda1";
1323     device[5] = devchar;
1324     int r;
1325     suppress_error = 0;
1326     r = guestfs_mkfs (g, fstype, device);
1327     if (r == -1)
1328       return -1;
1329   }
1330   {
1331     char device[] = "/dev/sda1";
1332     device[5] = devchar;
1333     char mountpoint[] = "/";
1334     int r;
1335     suppress_error = 0;
1336     r = guestfs_mount (g, device, mountpoint);
1337     if (r == -1)
1338       return -1;
1339   }
1340   /* TestOutput for cp (2) */
1341   char expected[] = "file content";
1342   {
1343     char path[] = "/old";
1344     char content[] = "file content";
1345     int r;
1346     suppress_error = 0;
1347     r = guestfs_write_file (g, path, content, 0);
1348     if (r == -1)
1349       return -1;
1350   }
1351   {
1352     char path[] = "/dir";
1353     int r;
1354     suppress_error = 0;
1355     r = guestfs_mkdir (g, path);
1356     if (r == -1)
1357       return -1;
1358   }
1359   {
1360     char src[] = "/old";
1361     char dest[] = "/dir/new";
1362     int r;
1363     suppress_error = 0;
1364     r = guestfs_cp (g, src, dest);
1365     if (r == -1)
1366       return -1;
1367   }
1368   {
1369     char path[] = "/dir/new";
1370     char *r;
1371     suppress_error = 0;
1372     r = guestfs_cat (g, path);
1373     if (r == NULL)
1374       return -1;
1375     if (strcmp (r, expected) != 0) {
1376       fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
1377       return -1;
1378     }
1379     free (r);
1380   }
1381   return 0;
1382 }
1383
1384 static int test_grub_install_0 (void)
1385 {
1386   /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
1387   {
1388     char device[] = "/dev/sda";
1389     device[5] = devchar;
1390     int r;
1391     suppress_error = 0;
1392     r = guestfs_blockdev_setrw (g, device);
1393     if (r == -1)
1394       return -1;
1395   }
1396   {
1397     int r;
1398     suppress_error = 0;
1399     r = guestfs_umount_all (g);
1400     if (r == -1)
1401       return -1;
1402   }
1403   {
1404     int r;
1405     suppress_error = 0;
1406     r = guestfs_lvm_remove_all (g);
1407     if (r == -1)
1408       return -1;
1409   }
1410   {
1411     char device[] = "/dev/sda";
1412     device[5] = devchar;
1413     char lines_0[] = ",";
1414     char *lines[] = {
1415       lines_0,
1416       NULL
1417     };
1418     int r;
1419     suppress_error = 0;
1420     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1421     if (r == -1)
1422       return -1;
1423   }
1424   {
1425     char fstype[] = "ext2";
1426     char device[] = "/dev/sda1";
1427     device[5] = devchar;
1428     int r;
1429     suppress_error = 0;
1430     r = guestfs_mkfs (g, fstype, device);
1431     if (r == -1)
1432       return -1;
1433   }
1434   {
1435     char device[] = "/dev/sda1";
1436     device[5] = devchar;
1437     char mountpoint[] = "/";
1438     int r;
1439     suppress_error = 0;
1440     r = guestfs_mount (g, device, mountpoint);
1441     if (r == -1)
1442       return -1;
1443   }
1444   /* TestOutputTrue for grub_install (0) */
1445   {
1446     char root[] = "/";
1447     char device[] = "/dev/sda1";
1448     device[5] = devchar;
1449     int r;
1450     suppress_error = 0;
1451     r = guestfs_grub_install (g, root, device);
1452     if (r == -1)
1453       return -1;
1454   }
1455   {
1456     char path[] = "/boot";
1457     int r;
1458     suppress_error = 0;
1459     r = guestfs_is_dir (g, path);
1460     if (r == -1)
1461       return -1;
1462     if (!r) {
1463       fprintf (stderr, "test_grub_install_0: expected true, got false\n");
1464       return -1;
1465     }
1466   }
1467   return 0;
1468 }
1469
1470 static int test_zero_0 (void)
1471 {
1472   /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
1473   {
1474     char device[] = "/dev/sda";
1475     device[5] = devchar;
1476     int r;
1477     suppress_error = 0;
1478     r = guestfs_blockdev_setrw (g, device);
1479     if (r == -1)
1480       return -1;
1481   }
1482   {
1483     int r;
1484     suppress_error = 0;
1485     r = guestfs_umount_all (g);
1486     if (r == -1)
1487       return -1;
1488   }
1489   {
1490     int r;
1491     suppress_error = 0;
1492     r = guestfs_lvm_remove_all (g);
1493     if (r == -1)
1494       return -1;
1495   }
1496   {
1497     char device[] = "/dev/sda";
1498     device[5] = devchar;
1499     char lines_0[] = ",";
1500     char *lines[] = {
1501       lines_0,
1502       NULL
1503     };
1504     int r;
1505     suppress_error = 0;
1506     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1507     if (r == -1)
1508       return -1;
1509   }
1510   {
1511     char fstype[] = "ext2";
1512     char device[] = "/dev/sda1";
1513     device[5] = devchar;
1514     int r;
1515     suppress_error = 0;
1516     r = guestfs_mkfs (g, fstype, device);
1517     if (r == -1)
1518       return -1;
1519   }
1520   {
1521     char device[] = "/dev/sda1";
1522     device[5] = devchar;
1523     char mountpoint[] = "/";
1524     int r;
1525     suppress_error = 0;
1526     r = guestfs_mount (g, device, mountpoint);
1527     if (r == -1)
1528       return -1;
1529   }
1530   /* TestOutput for zero (0) */
1531   char expected[] = "data";
1532   {
1533     char pathordevice[] = "/dev/sda1";
1534     pathordevice[5] = devchar;
1535     int r;
1536     suppress_error = 0;
1537     r = guestfs_umount (g, pathordevice);
1538     if (r == -1)
1539       return -1;
1540   }
1541   {
1542     char device[] = "/dev/sda1";
1543     device[5] = devchar;
1544     int r;
1545     suppress_error = 0;
1546     r = guestfs_zero (g, device);
1547     if (r == -1)
1548       return -1;
1549   }
1550   {
1551     char path[] = "/dev/sda1";
1552     path[5] = devchar;
1553     char *r;
1554     suppress_error = 0;
1555     r = guestfs_file (g, path);
1556     if (r == NULL)
1557       return -1;
1558     if (strcmp (r, expected) != 0) {
1559       fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
1560       return -1;
1561     }
1562     free (r);
1563   }
1564   return 0;
1565 }
1566
1567 static int test_fsck_0 (void)
1568 {
1569   /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
1570   {
1571     char device[] = "/dev/sda";
1572     device[5] = devchar;
1573     int r;
1574     suppress_error = 0;
1575     r = guestfs_blockdev_setrw (g, device);
1576     if (r == -1)
1577       return -1;
1578   }
1579   {
1580     int r;
1581     suppress_error = 0;
1582     r = guestfs_umount_all (g);
1583     if (r == -1)
1584       return -1;
1585   }
1586   {
1587     int r;
1588     suppress_error = 0;
1589     r = guestfs_lvm_remove_all (g);
1590     if (r == -1)
1591       return -1;
1592   }
1593   {
1594     char device[] = "/dev/sda";
1595     device[5] = devchar;
1596     char lines_0[] = ",";
1597     char *lines[] = {
1598       lines_0,
1599       NULL
1600     };
1601     int r;
1602     suppress_error = 0;
1603     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1604     if (r == -1)
1605       return -1;
1606   }
1607   {
1608     char fstype[] = "ext2";
1609     char device[] = "/dev/sda1";
1610     device[5] = devchar;
1611     int r;
1612     suppress_error = 0;
1613     r = guestfs_mkfs (g, fstype, device);
1614     if (r == -1)
1615       return -1;
1616   }
1617   {
1618     char device[] = "/dev/sda1";
1619     device[5] = devchar;
1620     char mountpoint[] = "/";
1621     int r;
1622     suppress_error = 0;
1623     r = guestfs_mount (g, device, mountpoint);
1624     if (r == -1)
1625       return -1;
1626   }
1627   /* TestOutputInt for fsck (0) */
1628   {
1629     char pathordevice[] = "/dev/sda1";
1630     pathordevice[5] = devchar;
1631     int r;
1632     suppress_error = 0;
1633     r = guestfs_umount (g, pathordevice);
1634     if (r == -1)
1635       return -1;
1636   }
1637   {
1638     char fstype[] = "ext2";
1639     char device[] = "/dev/sda1";
1640     device[5] = devchar;
1641     int r;
1642     suppress_error = 0;
1643     r = guestfs_fsck (g, fstype, device);
1644     if (r == -1)
1645       return -1;
1646     if (r != 0) {
1647       fprintf (stderr, "test_fsck_0: expected 0 but got %d\n",               (int) r);
1648       return -1;
1649     }
1650   }
1651   return 0;
1652 }
1653
1654 static int test_fsck_1 (void)
1655 {
1656   /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
1657   {
1658     char device[] = "/dev/sda";
1659     device[5] = devchar;
1660     int r;
1661     suppress_error = 0;
1662     r = guestfs_blockdev_setrw (g, device);
1663     if (r == -1)
1664       return -1;
1665   }
1666   {
1667     int r;
1668     suppress_error = 0;
1669     r = guestfs_umount_all (g);
1670     if (r == -1)
1671       return -1;
1672   }
1673   {
1674     int r;
1675     suppress_error = 0;
1676     r = guestfs_lvm_remove_all (g);
1677     if (r == -1)
1678       return -1;
1679   }
1680   {
1681     char device[] = "/dev/sda";
1682     device[5] = devchar;
1683     char lines_0[] = ",";
1684     char *lines[] = {
1685       lines_0,
1686       NULL
1687     };
1688     int r;
1689     suppress_error = 0;
1690     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1691     if (r == -1)
1692       return -1;
1693   }
1694   {
1695     char fstype[] = "ext2";
1696     char device[] = "/dev/sda1";
1697     device[5] = devchar;
1698     int r;
1699     suppress_error = 0;
1700     r = guestfs_mkfs (g, fstype, device);
1701     if (r == -1)
1702       return -1;
1703   }
1704   {
1705     char device[] = "/dev/sda1";
1706     device[5] = devchar;
1707     char mountpoint[] = "/";
1708     int r;
1709     suppress_error = 0;
1710     r = guestfs_mount (g, device, mountpoint);
1711     if (r == -1)
1712       return -1;
1713   }
1714   /* TestOutputInt for fsck (1) */
1715   {
1716     char pathordevice[] = "/dev/sda1";
1717     pathordevice[5] = devchar;
1718     int r;
1719     suppress_error = 0;
1720     r = guestfs_umount (g, pathordevice);
1721     if (r == -1)
1722       return -1;
1723   }
1724   {
1725     char device[] = "/dev/sda1";
1726     device[5] = devchar;
1727     int r;
1728     suppress_error = 0;
1729     r = guestfs_zero (g, device);
1730     if (r == -1)
1731       return -1;
1732   }
1733   {
1734     char fstype[] = "ext2";
1735     char device[] = "/dev/sda1";
1736     device[5] = devchar;
1737     int r;
1738     suppress_error = 0;
1739     r = guestfs_fsck (g, fstype, device);
1740     if (r == -1)
1741       return -1;
1742     if (r != 8) {
1743       fprintf (stderr, "test_fsck_1: expected 8 but got %d\n",               (int) r);
1744       return -1;
1745     }
1746   }
1747   return 0;
1748 }
1749
1750 static int test_set_e2uuid_0 (void)
1751 {
1752   /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
1753   {
1754     char device[] = "/dev/sda";
1755     device[5] = devchar;
1756     int r;
1757     suppress_error = 0;
1758     r = guestfs_blockdev_setrw (g, device);
1759     if (r == -1)
1760       return -1;
1761   }
1762   {
1763     int r;
1764     suppress_error = 0;
1765     r = guestfs_umount_all (g);
1766     if (r == -1)
1767       return -1;
1768   }
1769   {
1770     int r;
1771     suppress_error = 0;
1772     r = guestfs_lvm_remove_all (g);
1773     if (r == -1)
1774       return -1;
1775   }
1776   {
1777     char device[] = "/dev/sda";
1778     device[5] = devchar;
1779     char lines_0[] = ",";
1780     char *lines[] = {
1781       lines_0,
1782       NULL
1783     };
1784     int r;
1785     suppress_error = 0;
1786     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1787     if (r == -1)
1788       return -1;
1789   }
1790   {
1791     char fstype[] = "ext2";
1792     char device[] = "/dev/sda1";
1793     device[5] = devchar;
1794     int r;
1795     suppress_error = 0;
1796     r = guestfs_mkfs (g, fstype, device);
1797     if (r == -1)
1798       return -1;
1799   }
1800   {
1801     char device[] = "/dev/sda1";
1802     device[5] = devchar;
1803     char mountpoint[] = "/";
1804     int r;
1805     suppress_error = 0;
1806     r = guestfs_mount (g, device, mountpoint);
1807     if (r == -1)
1808       return -1;
1809   }
1810   /* TestOutput for set_e2uuid (0) */
1811   char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1812   {
1813     char device[] = "/dev/sda1";
1814     device[5] = devchar;
1815     char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1816     int r;
1817     suppress_error = 0;
1818     r = guestfs_set_e2uuid (g, device, uuid);
1819     if (r == -1)
1820       return -1;
1821   }
1822   {
1823     char device[] = "/dev/sda1";
1824     device[5] = devchar;
1825     char *r;
1826     suppress_error = 0;
1827     r = guestfs_get_e2uuid (g, device);
1828     if (r == NULL)
1829       return -1;
1830     if (strcmp (r, expected) != 0) {
1831       fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
1832       return -1;
1833     }
1834     free (r);
1835   }
1836   return 0;
1837 }
1838
1839 static int test_set_e2uuid_1 (void)
1840 {
1841   /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
1842   {
1843     char device[] = "/dev/sda";
1844     device[5] = devchar;
1845     int r;
1846     suppress_error = 0;
1847     r = guestfs_blockdev_setrw (g, device);
1848     if (r == -1)
1849       return -1;
1850   }
1851   {
1852     int r;
1853     suppress_error = 0;
1854     r = guestfs_umount_all (g);
1855     if (r == -1)
1856       return -1;
1857   }
1858   {
1859     int r;
1860     suppress_error = 0;
1861     r = guestfs_lvm_remove_all (g);
1862     if (r == -1)
1863       return -1;
1864   }
1865   {
1866     char device[] = "/dev/sda";
1867     device[5] = devchar;
1868     char lines_0[] = ",";
1869     char *lines[] = {
1870       lines_0,
1871       NULL
1872     };
1873     int r;
1874     suppress_error = 0;
1875     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1876     if (r == -1)
1877       return -1;
1878   }
1879   {
1880     char fstype[] = "ext2";
1881     char device[] = "/dev/sda1";
1882     device[5] = devchar;
1883     int r;
1884     suppress_error = 0;
1885     r = guestfs_mkfs (g, fstype, device);
1886     if (r == -1)
1887       return -1;
1888   }
1889   {
1890     char device[] = "/dev/sda1";
1891     device[5] = devchar;
1892     char mountpoint[] = "/";
1893     int r;
1894     suppress_error = 0;
1895     r = guestfs_mount (g, device, mountpoint);
1896     if (r == -1)
1897       return -1;
1898   }
1899   /* TestOutput for set_e2uuid (1) */
1900   char expected[] = "";
1901   {
1902     char device[] = "/dev/sda1";
1903     device[5] = devchar;
1904     char uuid[] = "clear";
1905     int r;
1906     suppress_error = 0;
1907     r = guestfs_set_e2uuid (g, device, uuid);
1908     if (r == -1)
1909       return -1;
1910   }
1911   {
1912     char device[] = "/dev/sda1";
1913     device[5] = devchar;
1914     char *r;
1915     suppress_error = 0;
1916     r = guestfs_get_e2uuid (g, device);
1917     if (r == NULL)
1918       return -1;
1919     if (strcmp (r, expected) != 0) {
1920       fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
1921       return -1;
1922     }
1923     free (r);
1924   }
1925   return 0;
1926 }
1927
1928 static int test_set_e2uuid_2 (void)
1929 {
1930   /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
1931   {
1932     char device[] = "/dev/sda";
1933     device[5] = devchar;
1934     int r;
1935     suppress_error = 0;
1936     r = guestfs_blockdev_setrw (g, device);
1937     if (r == -1)
1938       return -1;
1939   }
1940   {
1941     int r;
1942     suppress_error = 0;
1943     r = guestfs_umount_all (g);
1944     if (r == -1)
1945       return -1;
1946   }
1947   {
1948     int r;
1949     suppress_error = 0;
1950     r = guestfs_lvm_remove_all (g);
1951     if (r == -1)
1952       return -1;
1953   }
1954   {
1955     char device[] = "/dev/sda";
1956     device[5] = devchar;
1957     char lines_0[] = ",";
1958     char *lines[] = {
1959       lines_0,
1960       NULL
1961     };
1962     int r;
1963     suppress_error = 0;
1964     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1965     if (r == -1)
1966       return -1;
1967   }
1968   {
1969     char fstype[] = "ext2";
1970     char device[] = "/dev/sda1";
1971     device[5] = devchar;
1972     int r;
1973     suppress_error = 0;
1974     r = guestfs_mkfs (g, fstype, device);
1975     if (r == -1)
1976       return -1;
1977   }
1978   {
1979     char device[] = "/dev/sda1";
1980     device[5] = devchar;
1981     char mountpoint[] = "/";
1982     int r;
1983     suppress_error = 0;
1984     r = guestfs_mount (g, device, mountpoint);
1985     if (r == -1)
1986       return -1;
1987   }
1988   /* TestRun for set_e2uuid (2) */
1989   {
1990     char device[] = "/dev/sda1";
1991     device[5] = devchar;
1992     char uuid[] = "random";
1993     int r;
1994     suppress_error = 0;
1995     r = guestfs_set_e2uuid (g, device, uuid);
1996     if (r == -1)
1997       return -1;
1998   }
1999   return 0;
2000 }
2001
2002 static int test_set_e2uuid_3 (void)
2003 {
2004   /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
2005   {
2006     char device[] = "/dev/sda";
2007     device[5] = devchar;
2008     int r;
2009     suppress_error = 0;
2010     r = guestfs_blockdev_setrw (g, device);
2011     if (r == -1)
2012       return -1;
2013   }
2014   {
2015     int r;
2016     suppress_error = 0;
2017     r = guestfs_umount_all (g);
2018     if (r == -1)
2019       return -1;
2020   }
2021   {
2022     int r;
2023     suppress_error = 0;
2024     r = guestfs_lvm_remove_all (g);
2025     if (r == -1)
2026       return -1;
2027   }
2028   {
2029     char device[] = "/dev/sda";
2030     device[5] = devchar;
2031     char lines_0[] = ",";
2032     char *lines[] = {
2033       lines_0,
2034       NULL
2035     };
2036     int r;
2037     suppress_error = 0;
2038     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2039     if (r == -1)
2040       return -1;
2041   }
2042   {
2043     char fstype[] = "ext2";
2044     char device[] = "/dev/sda1";
2045     device[5] = devchar;
2046     int r;
2047     suppress_error = 0;
2048     r = guestfs_mkfs (g, fstype, device);
2049     if (r == -1)
2050       return -1;
2051   }
2052   {
2053     char device[] = "/dev/sda1";
2054     device[5] = devchar;
2055     char mountpoint[] = "/";
2056     int r;
2057     suppress_error = 0;
2058     r = guestfs_mount (g, device, mountpoint);
2059     if (r == -1)
2060       return -1;
2061   }
2062   /* TestRun for set_e2uuid (3) */
2063   {
2064     char device[] = "/dev/sda1";
2065     device[5] = devchar;
2066     char uuid[] = "time";
2067     int r;
2068     suppress_error = 0;
2069     r = guestfs_set_e2uuid (g, device, uuid);
2070     if (r == -1)
2071       return -1;
2072   }
2073   return 0;
2074 }
2075
2076 static int test_set_e2label_0 (void)
2077 {
2078   /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
2079   {
2080     char device[] = "/dev/sda";
2081     device[5] = devchar;
2082     int r;
2083     suppress_error = 0;
2084     r = guestfs_blockdev_setrw (g, device);
2085     if (r == -1)
2086       return -1;
2087   }
2088   {
2089     int r;
2090     suppress_error = 0;
2091     r = guestfs_umount_all (g);
2092     if (r == -1)
2093       return -1;
2094   }
2095   {
2096     int r;
2097     suppress_error = 0;
2098     r = guestfs_lvm_remove_all (g);
2099     if (r == -1)
2100       return -1;
2101   }
2102   {
2103     char device[] = "/dev/sda";
2104     device[5] = devchar;
2105     char lines_0[] = ",";
2106     char *lines[] = {
2107       lines_0,
2108       NULL
2109     };
2110     int r;
2111     suppress_error = 0;
2112     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2113     if (r == -1)
2114       return -1;
2115   }
2116   {
2117     char fstype[] = "ext2";
2118     char device[] = "/dev/sda1";
2119     device[5] = devchar;
2120     int r;
2121     suppress_error = 0;
2122     r = guestfs_mkfs (g, fstype, device);
2123     if (r == -1)
2124       return -1;
2125   }
2126   {
2127     char device[] = "/dev/sda1";
2128     device[5] = devchar;
2129     char mountpoint[] = "/";
2130     int r;
2131     suppress_error = 0;
2132     r = guestfs_mount (g, device, mountpoint);
2133     if (r == -1)
2134       return -1;
2135   }
2136   /* TestOutput for set_e2label (0) */
2137   char expected[] = "testlabel";
2138   {
2139     char device[] = "/dev/sda1";
2140     device[5] = devchar;
2141     char label[] = "testlabel";
2142     int r;
2143     suppress_error = 0;
2144     r = guestfs_set_e2label (g, device, label);
2145     if (r == -1)
2146       return -1;
2147   }
2148   {
2149     char device[] = "/dev/sda1";
2150     device[5] = devchar;
2151     char *r;
2152     suppress_error = 0;
2153     r = guestfs_get_e2label (g, device);
2154     if (r == NULL)
2155       return -1;
2156     if (strcmp (r, expected) != 0) {
2157       fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
2158       return -1;
2159     }
2160     free (r);
2161   }
2162   return 0;
2163 }
2164
2165 static int test_pvremove_0 (void)
2166 {
2167   /* InitEmpty for pvremove (0) */
2168   {
2169     char device[] = "/dev/sda";
2170     device[5] = devchar;
2171     int r;
2172     suppress_error = 0;
2173     r = guestfs_blockdev_setrw (g, device);
2174     if (r == -1)
2175       return -1;
2176   }
2177   {
2178     int r;
2179     suppress_error = 0;
2180     r = guestfs_umount_all (g);
2181     if (r == -1)
2182       return -1;
2183   }
2184   {
2185     int r;
2186     suppress_error = 0;
2187     r = guestfs_lvm_remove_all (g);
2188     if (r == -1)
2189       return -1;
2190   }
2191   /* TestOutputList for pvremove (0) */
2192   {
2193     char device[] = "/dev/sda";
2194     device[5] = devchar;
2195     int r;
2196     suppress_error = 0;
2197     r = guestfs_pvcreate (g, device);
2198     if (r == -1)
2199       return -1;
2200   }
2201   {
2202     char volgroup[] = "VG";
2203     char physvols_0[] = "/dev/sda";
2204     physvols_0[5] = devchar;
2205     char *physvols[] = {
2206       physvols_0,
2207       NULL
2208     };
2209     int r;
2210     suppress_error = 0;
2211     r = guestfs_vgcreate (g, volgroup, physvols);
2212     if (r == -1)
2213       return -1;
2214   }
2215   {
2216     char logvol[] = "LV1";
2217     char volgroup[] = "VG";
2218     int r;
2219     suppress_error = 0;
2220     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2221     if (r == -1)
2222       return -1;
2223   }
2224   {
2225     char logvol[] = "LV2";
2226     char volgroup[] = "VG";
2227     int r;
2228     suppress_error = 0;
2229     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2230     if (r == -1)
2231       return -1;
2232   }
2233   {
2234     char vgname[] = "VG";
2235     int r;
2236     suppress_error = 0;
2237     r = guestfs_vgremove (g, vgname);
2238     if (r == -1)
2239       return -1;
2240   }
2241   {
2242     char device[] = "/dev/sda";
2243     device[5] = devchar;
2244     int r;
2245     suppress_error = 0;
2246     r = guestfs_pvremove (g, device);
2247     if (r == -1)
2248       return -1;
2249   }
2250   {
2251     char **r;
2252     int i;
2253     suppress_error = 0;
2254     r = guestfs_lvs (g);
2255     if (r == NULL)
2256       return -1;
2257     if (r[0] != NULL) {
2258       fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
2259       print_strings (r);
2260       return -1;
2261     }
2262     for (i = 0; r[i] != NULL; ++i)
2263       free (r[i]);
2264     free (r);
2265   }
2266   return 0;
2267 }
2268
2269 static int test_pvremove_1 (void)
2270 {
2271   /* InitEmpty for pvremove (1) */
2272   {
2273     char device[] = "/dev/sda";
2274     device[5] = devchar;
2275     int r;
2276     suppress_error = 0;
2277     r = guestfs_blockdev_setrw (g, device);
2278     if (r == -1)
2279       return -1;
2280   }
2281   {
2282     int r;
2283     suppress_error = 0;
2284     r = guestfs_umount_all (g);
2285     if (r == -1)
2286       return -1;
2287   }
2288   {
2289     int r;
2290     suppress_error = 0;
2291     r = guestfs_lvm_remove_all (g);
2292     if (r == -1)
2293       return -1;
2294   }
2295   /* TestOutputList for pvremove (1) */
2296   {
2297     char device[] = "/dev/sda";
2298     device[5] = devchar;
2299     int r;
2300     suppress_error = 0;
2301     r = guestfs_pvcreate (g, device);
2302     if (r == -1)
2303       return -1;
2304   }
2305   {
2306     char volgroup[] = "VG";
2307     char physvols_0[] = "/dev/sda";
2308     physvols_0[5] = devchar;
2309     char *physvols[] = {
2310       physvols_0,
2311       NULL
2312     };
2313     int r;
2314     suppress_error = 0;
2315     r = guestfs_vgcreate (g, volgroup, physvols);
2316     if (r == -1)
2317       return -1;
2318   }
2319   {
2320     char logvol[] = "LV1";
2321     char volgroup[] = "VG";
2322     int r;
2323     suppress_error = 0;
2324     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2325     if (r == -1)
2326       return -1;
2327   }
2328   {
2329     char logvol[] = "LV2";
2330     char volgroup[] = "VG";
2331     int r;
2332     suppress_error = 0;
2333     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2334     if (r == -1)
2335       return -1;
2336   }
2337   {
2338     char vgname[] = "VG";
2339     int r;
2340     suppress_error = 0;
2341     r = guestfs_vgremove (g, vgname);
2342     if (r == -1)
2343       return -1;
2344   }
2345   {
2346     char device[] = "/dev/sda";
2347     device[5] = devchar;
2348     int r;
2349     suppress_error = 0;
2350     r = guestfs_pvremove (g, device);
2351     if (r == -1)
2352       return -1;
2353   }
2354   {
2355     char **r;
2356     int i;
2357     suppress_error = 0;
2358     r = guestfs_vgs (g);
2359     if (r == NULL)
2360       return -1;
2361     if (r[0] != NULL) {
2362       fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
2363       print_strings (r);
2364       return -1;
2365     }
2366     for (i = 0; r[i] != NULL; ++i)
2367       free (r[i]);
2368     free (r);
2369   }
2370   return 0;
2371 }
2372
2373 static int test_pvremove_2 (void)
2374 {
2375   /* InitEmpty for pvremove (2) */
2376   {
2377     char device[] = "/dev/sda";
2378     device[5] = devchar;
2379     int r;
2380     suppress_error = 0;
2381     r = guestfs_blockdev_setrw (g, device);
2382     if (r == -1)
2383       return -1;
2384   }
2385   {
2386     int r;
2387     suppress_error = 0;
2388     r = guestfs_umount_all (g);
2389     if (r == -1)
2390       return -1;
2391   }
2392   {
2393     int r;
2394     suppress_error = 0;
2395     r = guestfs_lvm_remove_all (g);
2396     if (r == -1)
2397       return -1;
2398   }
2399   /* TestOutputList for pvremove (2) */
2400   {
2401     char device[] = "/dev/sda";
2402     device[5] = devchar;
2403     int r;
2404     suppress_error = 0;
2405     r = guestfs_pvcreate (g, device);
2406     if (r == -1)
2407       return -1;
2408   }
2409   {
2410     char volgroup[] = "VG";
2411     char physvols_0[] = "/dev/sda";
2412     physvols_0[5] = devchar;
2413     char *physvols[] = {
2414       physvols_0,
2415       NULL
2416     };
2417     int r;
2418     suppress_error = 0;
2419     r = guestfs_vgcreate (g, volgroup, physvols);
2420     if (r == -1)
2421       return -1;
2422   }
2423   {
2424     char logvol[] = "LV1";
2425     char volgroup[] = "VG";
2426     int r;
2427     suppress_error = 0;
2428     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2429     if (r == -1)
2430       return -1;
2431   }
2432   {
2433     char logvol[] = "LV2";
2434     char volgroup[] = "VG";
2435     int r;
2436     suppress_error = 0;
2437     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2438     if (r == -1)
2439       return -1;
2440   }
2441   {
2442     char vgname[] = "VG";
2443     int r;
2444     suppress_error = 0;
2445     r = guestfs_vgremove (g, vgname);
2446     if (r == -1)
2447       return -1;
2448   }
2449   {
2450     char device[] = "/dev/sda";
2451     device[5] = devchar;
2452     int r;
2453     suppress_error = 0;
2454     r = guestfs_pvremove (g, device);
2455     if (r == -1)
2456       return -1;
2457   }
2458   {
2459     char **r;
2460     int i;
2461     suppress_error = 0;
2462     r = guestfs_pvs (g);
2463     if (r == NULL)
2464       return -1;
2465     if (r[0] != NULL) {
2466       fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
2467       print_strings (r);
2468       return -1;
2469     }
2470     for (i = 0; r[i] != NULL; ++i)
2471       free (r[i]);
2472     free (r);
2473   }
2474   return 0;
2475 }
2476
2477 static int test_vgremove_0 (void)
2478 {
2479   /* InitEmpty for vgremove (0) */
2480   {
2481     char device[] = "/dev/sda";
2482     device[5] = devchar;
2483     int r;
2484     suppress_error = 0;
2485     r = guestfs_blockdev_setrw (g, device);
2486     if (r == -1)
2487       return -1;
2488   }
2489   {
2490     int r;
2491     suppress_error = 0;
2492     r = guestfs_umount_all (g);
2493     if (r == -1)
2494       return -1;
2495   }
2496   {
2497     int r;
2498     suppress_error = 0;
2499     r = guestfs_lvm_remove_all (g);
2500     if (r == -1)
2501       return -1;
2502   }
2503   /* TestOutputList for vgremove (0) */
2504   {
2505     char device[] = "/dev/sda";
2506     device[5] = devchar;
2507     int r;
2508     suppress_error = 0;
2509     r = guestfs_pvcreate (g, device);
2510     if (r == -1)
2511       return -1;
2512   }
2513   {
2514     char volgroup[] = "VG";
2515     char physvols_0[] = "/dev/sda";
2516     physvols_0[5] = devchar;
2517     char *physvols[] = {
2518       physvols_0,
2519       NULL
2520     };
2521     int r;
2522     suppress_error = 0;
2523     r = guestfs_vgcreate (g, volgroup, physvols);
2524     if (r == -1)
2525       return -1;
2526   }
2527   {
2528     char logvol[] = "LV1";
2529     char volgroup[] = "VG";
2530     int r;
2531     suppress_error = 0;
2532     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2533     if (r == -1)
2534       return -1;
2535   }
2536   {
2537     char logvol[] = "LV2";
2538     char volgroup[] = "VG";
2539     int r;
2540     suppress_error = 0;
2541     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2542     if (r == -1)
2543       return -1;
2544   }
2545   {
2546     char vgname[] = "VG";
2547     int r;
2548     suppress_error = 0;
2549     r = guestfs_vgremove (g, vgname);
2550     if (r == -1)
2551       return -1;
2552   }
2553   {
2554     char **r;
2555     int i;
2556     suppress_error = 0;
2557     r = guestfs_lvs (g);
2558     if (r == NULL)
2559       return -1;
2560     if (r[0] != NULL) {
2561       fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
2562       print_strings (r);
2563       return -1;
2564     }
2565     for (i = 0; r[i] != NULL; ++i)
2566       free (r[i]);
2567     free (r);
2568   }
2569   return 0;
2570 }
2571
2572 static int test_vgremove_1 (void)
2573 {
2574   /* InitEmpty for vgremove (1) */
2575   {
2576     char device[] = "/dev/sda";
2577     device[5] = devchar;
2578     int r;
2579     suppress_error = 0;
2580     r = guestfs_blockdev_setrw (g, device);
2581     if (r == -1)
2582       return -1;
2583   }
2584   {
2585     int r;
2586     suppress_error = 0;
2587     r = guestfs_umount_all (g);
2588     if (r == -1)
2589       return -1;
2590   }
2591   {
2592     int r;
2593     suppress_error = 0;
2594     r = guestfs_lvm_remove_all (g);
2595     if (r == -1)
2596       return -1;
2597   }
2598   /* TestOutputList for vgremove (1) */
2599   {
2600     char device[] = "/dev/sda";
2601     device[5] = devchar;
2602     int r;
2603     suppress_error = 0;
2604     r = guestfs_pvcreate (g, device);
2605     if (r == -1)
2606       return -1;
2607   }
2608   {
2609     char volgroup[] = "VG";
2610     char physvols_0[] = "/dev/sda";
2611     physvols_0[5] = devchar;
2612     char *physvols[] = {
2613       physvols_0,
2614       NULL
2615     };
2616     int r;
2617     suppress_error = 0;
2618     r = guestfs_vgcreate (g, volgroup, physvols);
2619     if (r == -1)
2620       return -1;
2621   }
2622   {
2623     char logvol[] = "LV1";
2624     char volgroup[] = "VG";
2625     int r;
2626     suppress_error = 0;
2627     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2628     if (r == -1)
2629       return -1;
2630   }
2631   {
2632     char logvol[] = "LV2";
2633     char volgroup[] = "VG";
2634     int r;
2635     suppress_error = 0;
2636     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2637     if (r == -1)
2638       return -1;
2639   }
2640   {
2641     char vgname[] = "VG";
2642     int r;
2643     suppress_error = 0;
2644     r = guestfs_vgremove (g, vgname);
2645     if (r == -1)
2646       return -1;
2647   }
2648   {
2649     char **r;
2650     int i;
2651     suppress_error = 0;
2652     r = guestfs_vgs (g);
2653     if (r == NULL)
2654       return -1;
2655     if (r[0] != NULL) {
2656       fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
2657       print_strings (r);
2658       return -1;
2659     }
2660     for (i = 0; r[i] != NULL; ++i)
2661       free (r[i]);
2662     free (r);
2663   }
2664   return 0;
2665 }
2666
2667 static int test_lvremove_0 (void)
2668 {
2669   /* InitEmpty for lvremove (0) */
2670   {
2671     char device[] = "/dev/sda";
2672     device[5] = devchar;
2673     int r;
2674     suppress_error = 0;
2675     r = guestfs_blockdev_setrw (g, device);
2676     if (r == -1)
2677       return -1;
2678   }
2679   {
2680     int r;
2681     suppress_error = 0;
2682     r = guestfs_umount_all (g);
2683     if (r == -1)
2684       return -1;
2685   }
2686   {
2687     int r;
2688     suppress_error = 0;
2689     r = guestfs_lvm_remove_all (g);
2690     if (r == -1)
2691       return -1;
2692   }
2693   /* TestOutputList for lvremove (0) */
2694   {
2695     char device[] = "/dev/sda";
2696     device[5] = devchar;
2697     int r;
2698     suppress_error = 0;
2699     r = guestfs_pvcreate (g, device);
2700     if (r == -1)
2701       return -1;
2702   }
2703   {
2704     char volgroup[] = "VG";
2705     char physvols_0[] = "/dev/sda";
2706     physvols_0[5] = devchar;
2707     char *physvols[] = {
2708       physvols_0,
2709       NULL
2710     };
2711     int r;
2712     suppress_error = 0;
2713     r = guestfs_vgcreate (g, volgroup, physvols);
2714     if (r == -1)
2715       return -1;
2716   }
2717   {
2718     char logvol[] = "LV1";
2719     char volgroup[] = "VG";
2720     int r;
2721     suppress_error = 0;
2722     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2723     if (r == -1)
2724       return -1;
2725   }
2726   {
2727     char logvol[] = "LV2";
2728     char volgroup[] = "VG";
2729     int r;
2730     suppress_error = 0;
2731     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2732     if (r == -1)
2733       return -1;
2734   }
2735   {
2736     char device[] = "/dev/VG/LV1";
2737     int r;
2738     suppress_error = 0;
2739     r = guestfs_lvremove (g, device);
2740     if (r == -1)
2741       return -1;
2742   }
2743   {
2744     char **r;
2745     int i;
2746     suppress_error = 0;
2747     r = guestfs_lvs (g);
2748     if (r == NULL)
2749       return -1;
2750     if (!r[0]) {
2751       fprintf (stderr, "test_lvremove_0: short list returned from command\n");
2752       print_strings (r);
2753       return -1;
2754     }
2755     {
2756       char expected[] = "/dev/VG/LV2";
2757       if (strcmp (r[0], expected) != 0) {
2758         fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2759         return -1;
2760       }
2761     }
2762     if (r[1] != NULL) {
2763       fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
2764       print_strings (r);
2765       return -1;
2766     }
2767     for (i = 0; r[i] != NULL; ++i)
2768       free (r[i]);
2769     free (r);
2770   }
2771   return 0;
2772 }
2773
2774 static int test_lvremove_1 (void)
2775 {
2776   /* InitEmpty for lvremove (1) */
2777   {
2778     char device[] = "/dev/sda";
2779     device[5] = devchar;
2780     int r;
2781     suppress_error = 0;
2782     r = guestfs_blockdev_setrw (g, device);
2783     if (r == -1)
2784       return -1;
2785   }
2786   {
2787     int r;
2788     suppress_error = 0;
2789     r = guestfs_umount_all (g);
2790     if (r == -1)
2791       return -1;
2792   }
2793   {
2794     int r;
2795     suppress_error = 0;
2796     r = guestfs_lvm_remove_all (g);
2797     if (r == -1)
2798       return -1;
2799   }
2800   /* TestOutputList for lvremove (1) */
2801   {
2802     char device[] = "/dev/sda";
2803     device[5] = devchar;
2804     int r;
2805     suppress_error = 0;
2806     r = guestfs_pvcreate (g, device);
2807     if (r == -1)
2808       return -1;
2809   }
2810   {
2811     char volgroup[] = "VG";
2812     char physvols_0[] = "/dev/sda";
2813     physvols_0[5] = devchar;
2814     char *physvols[] = {
2815       physvols_0,
2816       NULL
2817     };
2818     int r;
2819     suppress_error = 0;
2820     r = guestfs_vgcreate (g, volgroup, physvols);
2821     if (r == -1)
2822       return -1;
2823   }
2824   {
2825     char logvol[] = "LV1";
2826     char volgroup[] = "VG";
2827     int r;
2828     suppress_error = 0;
2829     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2830     if (r == -1)
2831       return -1;
2832   }
2833   {
2834     char logvol[] = "LV2";
2835     char volgroup[] = "VG";
2836     int r;
2837     suppress_error = 0;
2838     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2839     if (r == -1)
2840       return -1;
2841   }
2842   {
2843     char device[] = "/dev/VG";
2844     int r;
2845     suppress_error = 0;
2846     r = guestfs_lvremove (g, device);
2847     if (r == -1)
2848       return -1;
2849   }
2850   {
2851     char **r;
2852     int i;
2853     suppress_error = 0;
2854     r = guestfs_lvs (g);
2855     if (r == NULL)
2856       return -1;
2857     if (r[0] != NULL) {
2858       fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
2859       print_strings (r);
2860       return -1;
2861     }
2862     for (i = 0; r[i] != NULL; ++i)
2863       free (r[i]);
2864     free (r);
2865   }
2866   return 0;
2867 }
2868
2869 static int test_lvremove_2 (void)
2870 {
2871   /* InitEmpty for lvremove (2) */
2872   {
2873     char device[] = "/dev/sda";
2874     device[5] = devchar;
2875     int r;
2876     suppress_error = 0;
2877     r = guestfs_blockdev_setrw (g, device);
2878     if (r == -1)
2879       return -1;
2880   }
2881   {
2882     int r;
2883     suppress_error = 0;
2884     r = guestfs_umount_all (g);
2885     if (r == -1)
2886       return -1;
2887   }
2888   {
2889     int r;
2890     suppress_error = 0;
2891     r = guestfs_lvm_remove_all (g);
2892     if (r == -1)
2893       return -1;
2894   }
2895   /* TestOutputList for lvremove (2) */
2896   {
2897     char device[] = "/dev/sda";
2898     device[5] = devchar;
2899     int r;
2900     suppress_error = 0;
2901     r = guestfs_pvcreate (g, device);
2902     if (r == -1)
2903       return -1;
2904   }
2905   {
2906     char volgroup[] = "VG";
2907     char physvols_0[] = "/dev/sda";
2908     physvols_0[5] = devchar;
2909     char *physvols[] = {
2910       physvols_0,
2911       NULL
2912     };
2913     int r;
2914     suppress_error = 0;
2915     r = guestfs_vgcreate (g, volgroup, physvols);
2916     if (r == -1)
2917       return -1;
2918   }
2919   {
2920     char logvol[] = "LV1";
2921     char volgroup[] = "VG";
2922     int r;
2923     suppress_error = 0;
2924     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2925     if (r == -1)
2926       return -1;
2927   }
2928   {
2929     char logvol[] = "LV2";
2930     char volgroup[] = "VG";
2931     int r;
2932     suppress_error = 0;
2933     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2934     if (r == -1)
2935       return -1;
2936   }
2937   {
2938     char device[] = "/dev/VG";
2939     int r;
2940     suppress_error = 0;
2941     r = guestfs_lvremove (g, device);
2942     if (r == -1)
2943       return -1;
2944   }
2945   {
2946     char **r;
2947     int i;
2948     suppress_error = 0;
2949     r = guestfs_vgs (g);
2950     if (r == NULL)
2951       return -1;
2952     if (!r[0]) {
2953       fprintf (stderr, "test_lvremove_2: short list returned from command\n");
2954       print_strings (r);
2955       return -1;
2956     }
2957     {
2958       char expected[] = "VG";
2959       if (strcmp (r[0], expected) != 0) {
2960         fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2961         return -1;
2962       }
2963     }
2964     if (r[1] != NULL) {
2965       fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
2966       print_strings (r);
2967       return -1;
2968     }
2969     for (i = 0; r[i] != NULL; ++i)
2970       free (r[i]);
2971     free (r);
2972   }
2973   return 0;
2974 }
2975
2976 static int test_mount_ro_0 (void)
2977 {
2978   /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
2979   {
2980     char device[] = "/dev/sda";
2981     device[5] = devchar;
2982     int r;
2983     suppress_error = 0;
2984     r = guestfs_blockdev_setrw (g, device);
2985     if (r == -1)
2986       return -1;
2987   }
2988   {
2989     int r;
2990     suppress_error = 0;
2991     r = guestfs_umount_all (g);
2992     if (r == -1)
2993       return -1;
2994   }
2995   {
2996     int r;
2997     suppress_error = 0;
2998     r = guestfs_lvm_remove_all (g);
2999     if (r == -1)
3000       return -1;
3001   }
3002   {
3003     char device[] = "/dev/sda";
3004     device[5] = devchar;
3005     char lines_0[] = ",";
3006     char *lines[] = {
3007       lines_0,
3008       NULL
3009     };
3010     int r;
3011     suppress_error = 0;
3012     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3013     if (r == -1)
3014       return -1;
3015   }
3016   {
3017     char fstype[] = "ext2";
3018     char device[] = "/dev/sda1";
3019     device[5] = devchar;
3020     int r;
3021     suppress_error = 0;
3022     r = guestfs_mkfs (g, fstype, device);
3023     if (r == -1)
3024       return -1;
3025   }
3026   {
3027     char device[] = "/dev/sda1";
3028     device[5] = devchar;
3029     char mountpoint[] = "/";
3030     int r;
3031     suppress_error = 0;
3032     r = guestfs_mount (g, device, mountpoint);
3033     if (r == -1)
3034       return -1;
3035   }
3036   /* TestLastFail for mount_ro (0) */
3037   {
3038     char pathordevice[] = "/";
3039     int r;
3040     suppress_error = 0;
3041     r = guestfs_umount (g, pathordevice);
3042     if (r == -1)
3043       return -1;
3044   }
3045   {
3046     char device[] = "/dev/sda1";
3047     device[5] = devchar;
3048     char mountpoint[] = "/";
3049     int r;
3050     suppress_error = 0;
3051     r = guestfs_mount_ro (g, device, mountpoint);
3052     if (r == -1)
3053       return -1;
3054   }
3055   {
3056     char path[] = "/new";
3057     int r;
3058     suppress_error = 1;
3059     r = guestfs_touch (g, path);
3060     if (r != -1)
3061       return -1;
3062   }
3063   return 0;
3064 }
3065
3066 static int test_mount_ro_1 (void)
3067 {
3068   /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
3069   {
3070     char device[] = "/dev/sda";
3071     device[5] = devchar;
3072     int r;
3073     suppress_error = 0;
3074     r = guestfs_blockdev_setrw (g, device);
3075     if (r == -1)
3076       return -1;
3077   }
3078   {
3079     int r;
3080     suppress_error = 0;
3081     r = guestfs_umount_all (g);
3082     if (r == -1)
3083       return -1;
3084   }
3085   {
3086     int r;
3087     suppress_error = 0;
3088     r = guestfs_lvm_remove_all (g);
3089     if (r == -1)
3090       return -1;
3091   }
3092   {
3093     char device[] = "/dev/sda";
3094     device[5] = devchar;
3095     char lines_0[] = ",";
3096     char *lines[] = {
3097       lines_0,
3098       NULL
3099     };
3100     int r;
3101     suppress_error = 0;
3102     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3103     if (r == -1)
3104       return -1;
3105   }
3106   {
3107     char fstype[] = "ext2";
3108     char device[] = "/dev/sda1";
3109     device[5] = devchar;
3110     int r;
3111     suppress_error = 0;
3112     r = guestfs_mkfs (g, fstype, device);
3113     if (r == -1)
3114       return -1;
3115   }
3116   {
3117     char device[] = "/dev/sda1";
3118     device[5] = devchar;
3119     char mountpoint[] = "/";
3120     int r;
3121     suppress_error = 0;
3122     r = guestfs_mount (g, device, mountpoint);
3123     if (r == -1)
3124       return -1;
3125   }
3126   /* TestOutput for mount_ro (1) */
3127   char expected[] = "data";
3128   {
3129     char path[] = "/new";
3130     char content[] = "data";
3131     int r;
3132     suppress_error = 0;
3133     r = guestfs_write_file (g, path, content, 0);
3134     if (r == -1)
3135       return -1;
3136   }
3137   {
3138     char pathordevice[] = "/";
3139     int r;
3140     suppress_error = 0;
3141     r = guestfs_umount (g, pathordevice);
3142     if (r == -1)
3143       return -1;
3144   }
3145   {
3146     char device[] = "/dev/sda1";
3147     device[5] = devchar;
3148     char mountpoint[] = "/";
3149     int r;
3150     suppress_error = 0;
3151     r = guestfs_mount_ro (g, device, mountpoint);
3152     if (r == -1)
3153       return -1;
3154   }
3155   {
3156     char path[] = "/new";
3157     char *r;
3158     suppress_error = 0;
3159     r = guestfs_cat (g, path);
3160     if (r == NULL)
3161       return -1;
3162     if (strcmp (r, expected) != 0) {
3163       fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
3164       return -1;
3165     }
3166     free (r);
3167   }
3168   return 0;
3169 }
3170
3171 static int test_tgz_in_0 (void)
3172 {
3173   /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
3174   {
3175     char device[] = "/dev/sda";
3176     device[5] = devchar;
3177     int r;
3178     suppress_error = 0;
3179     r = guestfs_blockdev_setrw (g, device);
3180     if (r == -1)
3181       return -1;
3182   }
3183   {
3184     int r;
3185     suppress_error = 0;
3186     r = guestfs_umount_all (g);
3187     if (r == -1)
3188       return -1;
3189   }
3190   {
3191     int r;
3192     suppress_error = 0;
3193     r = guestfs_lvm_remove_all (g);
3194     if (r == -1)
3195       return -1;
3196   }
3197   {
3198     char device[] = "/dev/sda";
3199     device[5] = devchar;
3200     char lines_0[] = ",";
3201     char *lines[] = {
3202       lines_0,
3203       NULL
3204     };
3205     int r;
3206     suppress_error = 0;
3207     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3208     if (r == -1)
3209       return -1;
3210   }
3211   {
3212     char fstype[] = "ext2";
3213     char device[] = "/dev/sda1";
3214     device[5] = devchar;
3215     int r;
3216     suppress_error = 0;
3217     r = guestfs_mkfs (g, fstype, device);
3218     if (r == -1)
3219       return -1;
3220   }
3221   {
3222     char device[] = "/dev/sda1";
3223     device[5] = devchar;
3224     char mountpoint[] = "/";
3225     int r;
3226     suppress_error = 0;
3227     r = guestfs_mount (g, device, mountpoint);
3228     if (r == -1)
3229       return -1;
3230   }
3231   /* TestOutput for tgz_in (0) */
3232   char expected[] = "hello\n";
3233   {
3234     char directory[] = "/";
3235     int r;
3236     suppress_error = 0;
3237     r = guestfs_tgz_in (g, "images/helloworld.tar.gz", directory);
3238     if (r == -1)
3239       return -1;
3240   }
3241   {
3242     char path[] = "/hello";
3243     char *r;
3244     suppress_error = 0;
3245     r = guestfs_cat (g, path);
3246     if (r == NULL)
3247       return -1;
3248     if (strcmp (r, expected) != 0) {
3249       fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3250       return -1;
3251     }
3252     free (r);
3253   }
3254   return 0;
3255 }
3256
3257 static int test_tar_in_0 (void)
3258 {
3259   /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
3260   {
3261     char device[] = "/dev/sda";
3262     device[5] = devchar;
3263     int r;
3264     suppress_error = 0;
3265     r = guestfs_blockdev_setrw (g, device);
3266     if (r == -1)
3267       return -1;
3268   }
3269   {
3270     int r;
3271     suppress_error = 0;
3272     r = guestfs_umount_all (g);
3273     if (r == -1)
3274       return -1;
3275   }
3276   {
3277     int r;
3278     suppress_error = 0;
3279     r = guestfs_lvm_remove_all (g);
3280     if (r == -1)
3281       return -1;
3282   }
3283   {
3284     char device[] = "/dev/sda";
3285     device[5] = devchar;
3286     char lines_0[] = ",";
3287     char *lines[] = {
3288       lines_0,
3289       NULL
3290     };
3291     int r;
3292     suppress_error = 0;
3293     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3294     if (r == -1)
3295       return -1;
3296   }
3297   {
3298     char fstype[] = "ext2";
3299     char device[] = "/dev/sda1";
3300     device[5] = devchar;
3301     int r;
3302     suppress_error = 0;
3303     r = guestfs_mkfs (g, fstype, device);
3304     if (r == -1)
3305       return -1;
3306   }
3307   {
3308     char device[] = "/dev/sda1";
3309     device[5] = devchar;
3310     char mountpoint[] = "/";
3311     int r;
3312     suppress_error = 0;
3313     r = guestfs_mount (g, device, mountpoint);
3314     if (r == -1)
3315       return -1;
3316   }
3317   /* TestOutput for tar_in (0) */
3318   char expected[] = "hello\n";
3319   {
3320     char directory[] = "/";
3321     int r;
3322     suppress_error = 0;
3323     r = guestfs_tar_in (g, "images/helloworld.tar", directory);
3324     if (r == -1)
3325       return -1;
3326   }
3327   {
3328     char path[] = "/hello";
3329     char *r;
3330     suppress_error = 0;
3331     r = guestfs_cat (g, path);
3332     if (r == NULL)
3333       return -1;
3334     if (strcmp (r, expected) != 0) {
3335       fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3336       return -1;
3337     }
3338     free (r);
3339   }
3340   return 0;
3341 }
3342
3343 static int test_checksum_0 (void)
3344 {
3345   /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
3346   {
3347     char device[] = "/dev/sda";
3348     device[5] = devchar;
3349     int r;
3350     suppress_error = 0;
3351     r = guestfs_blockdev_setrw (g, device);
3352     if (r == -1)
3353       return -1;
3354   }
3355   {
3356     int r;
3357     suppress_error = 0;
3358     r = guestfs_umount_all (g);
3359     if (r == -1)
3360       return -1;
3361   }
3362   {
3363     int r;
3364     suppress_error = 0;
3365     r = guestfs_lvm_remove_all (g);
3366     if (r == -1)
3367       return -1;
3368   }
3369   {
3370     char device[] = "/dev/sda";
3371     device[5] = devchar;
3372     char lines_0[] = ",";
3373     char *lines[] = {
3374       lines_0,
3375       NULL
3376     };
3377     int r;
3378     suppress_error = 0;
3379     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3380     if (r == -1)
3381       return -1;
3382   }
3383   {
3384     char fstype[] = "ext2";
3385     char device[] = "/dev/sda1";
3386     device[5] = devchar;
3387     int r;
3388     suppress_error = 0;
3389     r = guestfs_mkfs (g, fstype, device);
3390     if (r == -1)
3391       return -1;
3392   }
3393   {
3394     char device[] = "/dev/sda1";
3395     device[5] = devchar;
3396     char mountpoint[] = "/";
3397     int r;
3398     suppress_error = 0;
3399     r = guestfs_mount (g, device, mountpoint);
3400     if (r == -1)
3401       return -1;
3402   }
3403   /* TestOutput for checksum (0) */
3404   char expected[] = "935282863";
3405   {
3406     char path[] = "/new";
3407     char content[] = "test\n";
3408     int r;
3409     suppress_error = 0;
3410     r = guestfs_write_file (g, path, content, 0);
3411     if (r == -1)
3412       return -1;
3413   }
3414   {
3415     char csumtype[] = "crc";
3416     char path[] = "/new";
3417     char *r;
3418     suppress_error = 0;
3419     r = guestfs_checksum (g, csumtype, path);
3420     if (r == NULL)
3421       return -1;
3422     if (strcmp (r, expected) != 0) {
3423       fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
3424       return -1;
3425     }
3426     free (r);
3427   }
3428   return 0;
3429 }
3430
3431 static int test_checksum_1 (void)
3432 {
3433   /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
3434   {
3435     char device[] = "/dev/sda";
3436     device[5] = devchar;
3437     int r;
3438     suppress_error = 0;
3439     r = guestfs_blockdev_setrw (g, device);
3440     if (r == -1)
3441       return -1;
3442   }
3443   {
3444     int r;
3445     suppress_error = 0;
3446     r = guestfs_umount_all (g);
3447     if (r == -1)
3448       return -1;
3449   }
3450   {
3451     int r;
3452     suppress_error = 0;
3453     r = guestfs_lvm_remove_all (g);
3454     if (r == -1)
3455       return -1;
3456   }
3457   {
3458     char device[] = "/dev/sda";
3459     device[5] = devchar;
3460     char lines_0[] = ",";
3461     char *lines[] = {
3462       lines_0,
3463       NULL
3464     };
3465     int r;
3466     suppress_error = 0;
3467     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3468     if (r == -1)
3469       return -1;
3470   }
3471   {
3472     char fstype[] = "ext2";
3473     char device[] = "/dev/sda1";
3474     device[5] = devchar;
3475     int r;
3476     suppress_error = 0;
3477     r = guestfs_mkfs (g, fstype, device);
3478     if (r == -1)
3479       return -1;
3480   }
3481   {
3482     char device[] = "/dev/sda1";
3483     device[5] = devchar;
3484     char mountpoint[] = "/";
3485     int r;
3486     suppress_error = 0;
3487     r = guestfs_mount (g, device, mountpoint);
3488     if (r == -1)
3489       return -1;
3490   }
3491   /* TestLastFail for checksum (1) */
3492   {
3493     char csumtype[] = "crc";
3494     char path[] = "/new";
3495     char *r;
3496     suppress_error = 1;
3497     r = guestfs_checksum (g, csumtype, path);
3498     if (r != NULL)
3499       return -1;
3500     free (r);
3501   }
3502   return 0;
3503 }
3504
3505 static int test_checksum_2 (void)
3506 {
3507   /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
3508   {
3509     char device[] = "/dev/sda";
3510     device[5] = devchar;
3511     int r;
3512     suppress_error = 0;
3513     r = guestfs_blockdev_setrw (g, device);
3514     if (r == -1)
3515       return -1;
3516   }
3517   {
3518     int r;
3519     suppress_error = 0;
3520     r = guestfs_umount_all (g);
3521     if (r == -1)
3522       return -1;
3523   }
3524   {
3525     int r;
3526     suppress_error = 0;
3527     r = guestfs_lvm_remove_all (g);
3528     if (r == -1)
3529       return -1;
3530   }
3531   {
3532     char device[] = "/dev/sda";
3533     device[5] = devchar;
3534     char lines_0[] = ",";
3535     char *lines[] = {
3536       lines_0,
3537       NULL
3538     };
3539     int r;
3540     suppress_error = 0;
3541     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3542     if (r == -1)
3543       return -1;
3544   }
3545   {
3546     char fstype[] = "ext2";
3547     char device[] = "/dev/sda1";
3548     device[5] = devchar;
3549     int r;
3550     suppress_error = 0;
3551     r = guestfs_mkfs (g, fstype, device);
3552     if (r == -1)
3553       return -1;
3554   }
3555   {
3556     char device[] = "/dev/sda1";
3557     device[5] = devchar;
3558     char mountpoint[] = "/";
3559     int r;
3560     suppress_error = 0;
3561     r = guestfs_mount (g, device, mountpoint);
3562     if (r == -1)
3563       return -1;
3564   }
3565   /* TestOutput for checksum (2) */
3566   char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
3567   {
3568     char path[] = "/new";
3569     char content[] = "test\n";
3570     int r;
3571     suppress_error = 0;
3572     r = guestfs_write_file (g, path, content, 0);
3573     if (r == -1)
3574       return -1;
3575   }
3576   {
3577     char csumtype[] = "md5";
3578     char path[] = "/new";
3579     char *r;
3580     suppress_error = 0;
3581     r = guestfs_checksum (g, csumtype, path);
3582     if (r == NULL)
3583       return -1;
3584     if (strcmp (r, expected) != 0) {
3585       fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
3586       return -1;
3587     }
3588     free (r);
3589   }
3590   return 0;
3591 }
3592
3593 static int test_checksum_3 (void)
3594 {
3595   /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
3596   {
3597     char device[] = "/dev/sda";
3598     device[5] = devchar;
3599     int r;
3600     suppress_error = 0;
3601     r = guestfs_blockdev_setrw (g, device);
3602     if (r == -1)
3603       return -1;
3604   }
3605   {
3606     int r;
3607     suppress_error = 0;
3608     r = guestfs_umount_all (g);
3609     if (r == -1)
3610       return -1;
3611   }
3612   {
3613     int r;
3614     suppress_error = 0;
3615     r = guestfs_lvm_remove_all (g);
3616     if (r == -1)
3617       return -1;
3618   }
3619   {
3620     char device[] = "/dev/sda";
3621     device[5] = devchar;
3622     char lines_0[] = ",";
3623     char *lines[] = {
3624       lines_0,
3625       NULL
3626     };
3627     int r;
3628     suppress_error = 0;
3629     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3630     if (r == -1)
3631       return -1;
3632   }
3633   {
3634     char fstype[] = "ext2";
3635     char device[] = "/dev/sda1";
3636     device[5] = devchar;
3637     int r;
3638     suppress_error = 0;
3639     r = guestfs_mkfs (g, fstype, device);
3640     if (r == -1)
3641       return -1;
3642   }
3643   {
3644     char device[] = "/dev/sda1";
3645     device[5] = devchar;
3646     char mountpoint[] = "/";
3647     int r;
3648     suppress_error = 0;
3649     r = guestfs_mount (g, device, mountpoint);
3650     if (r == -1)
3651       return -1;
3652   }
3653   /* TestOutput for checksum (3) */
3654   char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
3655   {
3656     char path[] = "/new";
3657     char content[] = "test\n";
3658     int r;
3659     suppress_error = 0;
3660     r = guestfs_write_file (g, path, content, 0);
3661     if (r == -1)
3662       return -1;
3663   }
3664   {
3665     char csumtype[] = "sha1";
3666     char path[] = "/new";
3667     char *r;
3668     suppress_error = 0;
3669     r = guestfs_checksum (g, csumtype, path);
3670     if (r == NULL)
3671       return -1;
3672     if (strcmp (r, expected) != 0) {
3673       fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
3674       return -1;
3675     }
3676     free (r);
3677   }
3678   return 0;
3679 }
3680
3681 static int test_checksum_4 (void)
3682 {
3683   /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
3684   {
3685     char device[] = "/dev/sda";
3686     device[5] = devchar;
3687     int r;
3688     suppress_error = 0;
3689     r = guestfs_blockdev_setrw (g, device);
3690     if (r == -1)
3691       return -1;
3692   }
3693   {
3694     int r;
3695     suppress_error = 0;
3696     r = guestfs_umount_all (g);
3697     if (r == -1)
3698       return -1;
3699   }
3700   {
3701     int r;
3702     suppress_error = 0;
3703     r = guestfs_lvm_remove_all (g);
3704     if (r == -1)
3705       return -1;
3706   }
3707   {
3708     char device[] = "/dev/sda";
3709     device[5] = devchar;
3710     char lines_0[] = ",";
3711     char *lines[] = {
3712       lines_0,
3713       NULL
3714     };
3715     int r;
3716     suppress_error = 0;
3717     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3718     if (r == -1)
3719       return -1;
3720   }
3721   {
3722     char fstype[] = "ext2";
3723     char device[] = "/dev/sda1";
3724     device[5] = devchar;
3725     int r;
3726     suppress_error = 0;
3727     r = guestfs_mkfs (g, fstype, device);
3728     if (r == -1)
3729       return -1;
3730   }
3731   {
3732     char device[] = "/dev/sda1";
3733     device[5] = devchar;
3734     char mountpoint[] = "/";
3735     int r;
3736     suppress_error = 0;
3737     r = guestfs_mount (g, device, mountpoint);
3738     if (r == -1)
3739       return -1;
3740   }
3741   /* TestOutput for checksum (4) */
3742   char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
3743   {
3744     char path[] = "/new";
3745     char content[] = "test\n";
3746     int r;
3747     suppress_error = 0;
3748     r = guestfs_write_file (g, path, content, 0);
3749     if (r == -1)
3750       return -1;
3751   }
3752   {
3753     char csumtype[] = "sha224";
3754     char path[] = "/new";
3755     char *r;
3756     suppress_error = 0;
3757     r = guestfs_checksum (g, csumtype, path);
3758     if (r == NULL)
3759       return -1;
3760     if (strcmp (r, expected) != 0) {
3761       fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
3762       return -1;
3763     }
3764     free (r);
3765   }
3766   return 0;
3767 }
3768
3769 static int test_checksum_5 (void)
3770 {
3771   /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
3772   {
3773     char device[] = "/dev/sda";
3774     device[5] = devchar;
3775     int r;
3776     suppress_error = 0;
3777     r = guestfs_blockdev_setrw (g, device);
3778     if (r == -1)
3779       return -1;
3780   }
3781   {
3782     int r;
3783     suppress_error = 0;
3784     r = guestfs_umount_all (g);
3785     if (r == -1)
3786       return -1;
3787   }
3788   {
3789     int r;
3790     suppress_error = 0;
3791     r = guestfs_lvm_remove_all (g);
3792     if (r == -1)
3793       return -1;
3794   }
3795   {
3796     char device[] = "/dev/sda";
3797     device[5] = devchar;
3798     char lines_0[] = ",";
3799     char *lines[] = {
3800       lines_0,
3801       NULL
3802     };
3803     int r;
3804     suppress_error = 0;
3805     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3806     if (r == -1)
3807       return -1;
3808   }
3809   {
3810     char fstype[] = "ext2";
3811     char device[] = "/dev/sda1";
3812     device[5] = devchar;
3813     int r;
3814     suppress_error = 0;
3815     r = guestfs_mkfs (g, fstype, device);
3816     if (r == -1)
3817       return -1;
3818   }
3819   {
3820     char device[] = "/dev/sda1";
3821     device[5] = devchar;
3822     char mountpoint[] = "/";
3823     int r;
3824     suppress_error = 0;
3825     r = guestfs_mount (g, device, mountpoint);
3826     if (r == -1)
3827       return -1;
3828   }
3829   /* TestOutput for checksum (5) */
3830   char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
3831   {
3832     char path[] = "/new";
3833     char content[] = "test\n";
3834     int r;
3835     suppress_error = 0;
3836     r = guestfs_write_file (g, path, content, 0);
3837     if (r == -1)
3838       return -1;
3839   }
3840   {
3841     char csumtype[] = "sha256";
3842     char path[] = "/new";
3843     char *r;
3844     suppress_error = 0;
3845     r = guestfs_checksum (g, csumtype, path);
3846     if (r == NULL)
3847       return -1;
3848     if (strcmp (r, expected) != 0) {
3849       fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
3850       return -1;
3851     }
3852     free (r);
3853   }
3854   return 0;
3855 }
3856
3857 static int test_checksum_6 (void)
3858 {
3859   /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
3860   {
3861     char device[] = "/dev/sda";
3862     device[5] = devchar;
3863     int r;
3864     suppress_error = 0;
3865     r = guestfs_blockdev_setrw (g, device);
3866     if (r == -1)
3867       return -1;
3868   }
3869   {
3870     int r;
3871     suppress_error = 0;
3872     r = guestfs_umount_all (g);
3873     if (r == -1)
3874       return -1;
3875   }
3876   {
3877     int r;
3878     suppress_error = 0;
3879     r = guestfs_lvm_remove_all (g);
3880     if (r == -1)
3881       return -1;
3882   }
3883   {
3884     char device[] = "/dev/sda";
3885     device[5] = devchar;
3886     char lines_0[] = ",";
3887     char *lines[] = {
3888       lines_0,
3889       NULL
3890     };
3891     int r;
3892     suppress_error = 0;
3893     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3894     if (r == -1)
3895       return -1;
3896   }
3897   {
3898     char fstype[] = "ext2";
3899     char device[] = "/dev/sda1";
3900     device[5] = devchar;
3901     int r;
3902     suppress_error = 0;
3903     r = guestfs_mkfs (g, fstype, device);
3904     if (r == -1)
3905       return -1;
3906   }
3907   {
3908     char device[] = "/dev/sda1";
3909     device[5] = devchar;
3910     char mountpoint[] = "/";
3911     int r;
3912     suppress_error = 0;
3913     r = guestfs_mount (g, device, mountpoint);
3914     if (r == -1)
3915       return -1;
3916   }
3917   /* TestOutput for checksum (6) */
3918   char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
3919   {
3920     char path[] = "/new";
3921     char content[] = "test\n";
3922     int r;
3923     suppress_error = 0;
3924     r = guestfs_write_file (g, path, content, 0);
3925     if (r == -1)
3926       return -1;
3927   }
3928   {
3929     char csumtype[] = "sha384";
3930     char path[] = "/new";
3931     char *r;
3932     suppress_error = 0;
3933     r = guestfs_checksum (g, csumtype, path);
3934     if (r == NULL)
3935       return -1;
3936     if (strcmp (r, expected) != 0) {
3937       fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
3938       return -1;
3939     }
3940     free (r);
3941   }
3942   return 0;
3943 }
3944
3945 static int test_checksum_7 (void)
3946 {
3947   /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
3948   {
3949     char device[] = "/dev/sda";
3950     device[5] = devchar;
3951     int r;
3952     suppress_error = 0;
3953     r = guestfs_blockdev_setrw (g, device);
3954     if (r == -1)
3955       return -1;
3956   }
3957   {
3958     int r;
3959     suppress_error = 0;
3960     r = guestfs_umount_all (g);
3961     if (r == -1)
3962       return -1;
3963   }
3964   {
3965     int r;
3966     suppress_error = 0;
3967     r = guestfs_lvm_remove_all (g);
3968     if (r == -1)
3969       return -1;
3970   }
3971   {
3972     char device[] = "/dev/sda";
3973     device[5] = devchar;
3974     char lines_0[] = ",";
3975     char *lines[] = {
3976       lines_0,
3977       NULL
3978     };
3979     int r;
3980     suppress_error = 0;
3981     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3982     if (r == -1)
3983       return -1;
3984   }
3985   {
3986     char fstype[] = "ext2";
3987     char device[] = "/dev/sda1";
3988     device[5] = devchar;
3989     int r;
3990     suppress_error = 0;
3991     r = guestfs_mkfs (g, fstype, device);
3992     if (r == -1)
3993       return -1;
3994   }
3995   {
3996     char device[] = "/dev/sda1";
3997     device[5] = devchar;
3998     char mountpoint[] = "/";
3999     int r;
4000     suppress_error = 0;
4001     r = guestfs_mount (g, device, mountpoint);
4002     if (r == -1)
4003       return -1;
4004   }
4005   /* TestOutput for checksum (7) */
4006   char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
4007   {
4008     char path[] = "/new";
4009     char content[] = "test\n";
4010     int r;
4011     suppress_error = 0;
4012     r = guestfs_write_file (g, path, content, 0);
4013     if (r == -1)
4014       return -1;
4015   }
4016   {
4017     char csumtype[] = "sha512";
4018     char path[] = "/new";
4019     char *r;
4020     suppress_error = 0;
4021     r = guestfs_checksum (g, csumtype, path);
4022     if (r == NULL)
4023       return -1;
4024     if (strcmp (r, expected) != 0) {
4025       fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
4026       return -1;
4027     }
4028     free (r);
4029   }
4030   return 0;
4031 }
4032
4033 static int test_download_0 (void)
4034 {
4035   /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
4036   {
4037     char device[] = "/dev/sda";
4038     device[5] = devchar;
4039     int r;
4040     suppress_error = 0;
4041     r = guestfs_blockdev_setrw (g, device);
4042     if (r == -1)
4043       return -1;
4044   }
4045   {
4046     int r;
4047     suppress_error = 0;
4048     r = guestfs_umount_all (g);
4049     if (r == -1)
4050       return -1;
4051   }
4052   {
4053     int r;
4054     suppress_error = 0;
4055     r = guestfs_lvm_remove_all (g);
4056     if (r == -1)
4057       return -1;
4058   }
4059   {
4060     char device[] = "/dev/sda";
4061     device[5] = devchar;
4062     char lines_0[] = ",";
4063     char *lines[] = {
4064       lines_0,
4065       NULL
4066     };
4067     int r;
4068     suppress_error = 0;
4069     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4070     if (r == -1)
4071       return -1;
4072   }
4073   {
4074     char fstype[] = "ext2";
4075     char device[] = "/dev/sda1";
4076     device[5] = devchar;
4077     int r;
4078     suppress_error = 0;
4079     r = guestfs_mkfs (g, fstype, device);
4080     if (r == -1)
4081       return -1;
4082   }
4083   {
4084     char device[] = "/dev/sda1";
4085     device[5] = devchar;
4086     char mountpoint[] = "/";
4087     int r;
4088     suppress_error = 0;
4089     r = guestfs_mount (g, device, mountpoint);
4090     if (r == -1)
4091       return -1;
4092   }
4093   /* TestOutput for download (0) */
4094   char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4095   {
4096     char remotefilename[] = "/COPYING.LIB";
4097     int r;
4098     suppress_error = 0;
4099     r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4100     if (r == -1)
4101       return -1;
4102   }
4103   {
4104     char remotefilename[] = "/COPYING.LIB";
4105     int r;
4106     suppress_error = 0;
4107     r = guestfs_download (g, remotefilename, "testdownload.tmp");
4108     if (r == -1)
4109       return -1;
4110   }
4111   {
4112     char remotefilename[] = "/upload";
4113     int r;
4114     suppress_error = 0;
4115     r = guestfs_upload (g, "testdownload.tmp", remotefilename);
4116     if (r == -1)
4117       return -1;
4118   }
4119   {
4120     char csumtype[] = "md5";
4121     char path[] = "/upload";
4122     char *r;
4123     suppress_error = 0;
4124     r = guestfs_checksum (g, csumtype, path);
4125     if (r == NULL)
4126       return -1;
4127     if (strcmp (r, expected) != 0) {
4128       fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
4129       return -1;
4130     }
4131     free (r);
4132   }
4133   return 0;
4134 }
4135
4136 static int test_upload_0 (void)
4137 {
4138   /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
4139   {
4140     char device[] = "/dev/sda";
4141     device[5] = devchar;
4142     int r;
4143     suppress_error = 0;
4144     r = guestfs_blockdev_setrw (g, device);
4145     if (r == -1)
4146       return -1;
4147   }
4148   {
4149     int r;
4150     suppress_error = 0;
4151     r = guestfs_umount_all (g);
4152     if (r == -1)
4153       return -1;
4154   }
4155   {
4156     int r;
4157     suppress_error = 0;
4158     r = guestfs_lvm_remove_all (g);
4159     if (r == -1)
4160       return -1;
4161   }
4162   {
4163     char device[] = "/dev/sda";
4164     device[5] = devchar;
4165     char lines_0[] = ",";
4166     char *lines[] = {
4167       lines_0,
4168       NULL
4169     };
4170     int r;
4171     suppress_error = 0;
4172     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4173     if (r == -1)
4174       return -1;
4175   }
4176   {
4177     char fstype[] = "ext2";
4178     char device[] = "/dev/sda1";
4179     device[5] = devchar;
4180     int r;
4181     suppress_error = 0;
4182     r = guestfs_mkfs (g, fstype, device);
4183     if (r == -1)
4184       return -1;
4185   }
4186   {
4187     char device[] = "/dev/sda1";
4188     device[5] = devchar;
4189     char mountpoint[] = "/";
4190     int r;
4191     suppress_error = 0;
4192     r = guestfs_mount (g, device, mountpoint);
4193     if (r == -1)
4194       return -1;
4195   }
4196   /* TestOutput for upload (0) */
4197   char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4198   {
4199     char remotefilename[] = "/COPYING.LIB";
4200     int r;
4201     suppress_error = 0;
4202     r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4203     if (r == -1)
4204       return -1;
4205   }
4206   {
4207     char csumtype[] = "md5";
4208     char path[] = "/COPYING.LIB";
4209     char *r;
4210     suppress_error = 0;
4211     r = guestfs_checksum (g, csumtype, path);
4212     if (r == NULL)
4213       return -1;
4214     if (strcmp (r, expected) != 0) {
4215       fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
4216       return -1;
4217     }
4218     free (r);
4219   }
4220   return 0;
4221 }
4222
4223 static int test_blockdev_rereadpt_0 (void)
4224 {
4225   /* InitEmpty for blockdev_rereadpt (0) */
4226   {
4227     char device[] = "/dev/sda";
4228     device[5] = devchar;
4229     int r;
4230     suppress_error = 0;
4231     r = guestfs_blockdev_setrw (g, device);
4232     if (r == -1)
4233       return -1;
4234   }
4235   {
4236     int r;
4237     suppress_error = 0;
4238     r = guestfs_umount_all (g);
4239     if (r == -1)
4240       return -1;
4241   }
4242   {
4243     int r;
4244     suppress_error = 0;
4245     r = guestfs_lvm_remove_all (g);
4246     if (r == -1)
4247       return -1;
4248   }
4249   /* TestRun for blockdev_rereadpt (0) */
4250   {
4251     char device[] = "/dev/sda";
4252     device[5] = devchar;
4253     int r;
4254     suppress_error = 0;
4255     r = guestfs_blockdev_rereadpt (g, device);
4256     if (r == -1)
4257       return -1;
4258   }
4259   return 0;
4260 }
4261
4262 static int test_blockdev_flushbufs_0 (void)
4263 {
4264   /* InitEmpty for blockdev_flushbufs (0) */
4265   {
4266     char device[] = "/dev/sda";
4267     device[5] = devchar;
4268     int r;
4269     suppress_error = 0;
4270     r = guestfs_blockdev_setrw (g, device);
4271     if (r == -1)
4272       return -1;
4273   }
4274   {
4275     int r;
4276     suppress_error = 0;
4277     r = guestfs_umount_all (g);
4278     if (r == -1)
4279       return -1;
4280   }
4281   {
4282     int r;
4283     suppress_error = 0;
4284     r = guestfs_lvm_remove_all (g);
4285     if (r == -1)
4286       return -1;
4287   }
4288   /* TestRun for blockdev_flushbufs (0) */
4289   {
4290     char device[] = "/dev/sda";
4291     device[5] = devchar;
4292     int r;
4293     suppress_error = 0;
4294     r = guestfs_blockdev_flushbufs (g, device);
4295     if (r == -1)
4296       return -1;
4297   }
4298   return 0;
4299 }
4300
4301 static int test_blockdev_getsize64_0 (void)
4302 {
4303   /* InitEmpty for blockdev_getsize64 (0) */
4304   {
4305     char device[] = "/dev/sda";
4306     device[5] = devchar;
4307     int r;
4308     suppress_error = 0;
4309     r = guestfs_blockdev_setrw (g, device);
4310     if (r == -1)
4311       return -1;
4312   }
4313   {
4314     int r;
4315     suppress_error = 0;
4316     r = guestfs_umount_all (g);
4317     if (r == -1)
4318       return -1;
4319   }
4320   {
4321     int r;
4322     suppress_error = 0;
4323     r = guestfs_lvm_remove_all (g);
4324     if (r == -1)
4325       return -1;
4326   }
4327   /* TestOutputInt for blockdev_getsize64 (0) */
4328   {
4329     char device[] = "/dev/sda";
4330     device[5] = devchar;
4331     int64_t r;
4332     suppress_error = 0;
4333     r = guestfs_blockdev_getsize64 (g, device);
4334     if (r == -1)
4335       return -1;
4336     if (r != 524288000) {
4337       fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n",               (int) r);
4338       return -1;
4339     }
4340   }
4341   return 0;
4342 }
4343
4344 static int test_blockdev_getsz_0 (void)
4345 {
4346   /* InitEmpty for blockdev_getsz (0) */
4347   {
4348     char device[] = "/dev/sda";
4349     device[5] = devchar;
4350     int r;
4351     suppress_error = 0;
4352     r = guestfs_blockdev_setrw (g, device);
4353     if (r == -1)
4354       return -1;
4355   }
4356   {
4357     int r;
4358     suppress_error = 0;
4359     r = guestfs_umount_all (g);
4360     if (r == -1)
4361       return -1;
4362   }
4363   {
4364     int r;
4365     suppress_error = 0;
4366     r = guestfs_lvm_remove_all (g);
4367     if (r == -1)
4368       return -1;
4369   }
4370   /* TestOutputInt for blockdev_getsz (0) */
4371   {
4372     char device[] = "/dev/sda";
4373     device[5] = devchar;
4374     int64_t r;
4375     suppress_error = 0;
4376     r = guestfs_blockdev_getsz (g, device);
4377     if (r == -1)
4378       return -1;
4379     if (r != 1024000) {
4380       fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n",               (int) r);
4381       return -1;
4382     }
4383   }
4384   return 0;
4385 }
4386
4387 static int test_blockdev_getbsz_0 (void)
4388 {
4389   /* InitEmpty for blockdev_getbsz (0) */
4390   {
4391     char device[] = "/dev/sda";
4392     device[5] = devchar;
4393     int r;
4394     suppress_error = 0;
4395     r = guestfs_blockdev_setrw (g, device);
4396     if (r == -1)
4397       return -1;
4398   }
4399   {
4400     int r;
4401     suppress_error = 0;
4402     r = guestfs_umount_all (g);
4403     if (r == -1)
4404       return -1;
4405   }
4406   {
4407     int r;
4408     suppress_error = 0;
4409     r = guestfs_lvm_remove_all (g);
4410     if (r == -1)
4411       return -1;
4412   }
4413   /* TestOutputInt for blockdev_getbsz (0) */
4414   {
4415     char device[] = "/dev/sda";
4416     device[5] = devchar;
4417     int r;
4418     suppress_error = 0;
4419     r = guestfs_blockdev_getbsz (g, device);
4420     if (r == -1)
4421       return -1;
4422     if (r != 4096) {
4423       fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n",               (int) r);
4424       return -1;
4425     }
4426   }
4427   return 0;
4428 }
4429
4430 static int test_blockdev_getss_0 (void)
4431 {
4432   /* InitEmpty for blockdev_getss (0) */
4433   {
4434     char device[] = "/dev/sda";
4435     device[5] = devchar;
4436     int r;
4437     suppress_error = 0;
4438     r = guestfs_blockdev_setrw (g, device);
4439     if (r == -1)
4440       return -1;
4441   }
4442   {
4443     int r;
4444     suppress_error = 0;
4445     r = guestfs_umount_all (g);
4446     if (r == -1)
4447       return -1;
4448   }
4449   {
4450     int r;
4451     suppress_error = 0;
4452     r = guestfs_lvm_remove_all (g);
4453     if (r == -1)
4454       return -1;
4455   }
4456   /* TestOutputInt for blockdev_getss (0) */
4457   {
4458     char device[] = "/dev/sda";
4459     device[5] = devchar;
4460     int r;
4461     suppress_error = 0;
4462     r = guestfs_blockdev_getss (g, device);
4463     if (r == -1)
4464       return -1;
4465     if (r != 512) {
4466       fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n",               (int) r);
4467       return -1;
4468     }
4469   }
4470   return 0;
4471 }
4472
4473 static int test_blockdev_getro_0 (void)
4474 {
4475   /* InitEmpty for blockdev_getro (0) */
4476   {
4477     char device[] = "/dev/sda";
4478     device[5] = devchar;
4479     int r;
4480     suppress_error = 0;
4481     r = guestfs_blockdev_setrw (g, device);
4482     if (r == -1)
4483       return -1;
4484   }
4485   {
4486     int r;
4487     suppress_error = 0;
4488     r = guestfs_umount_all (g);
4489     if (r == -1)
4490       return -1;
4491   }
4492   {
4493     int r;
4494     suppress_error = 0;
4495     r = guestfs_lvm_remove_all (g);
4496     if (r == -1)
4497       return -1;
4498   }
4499   /* TestOutputTrue for blockdev_getro (0) */
4500   {
4501     char device[] = "/dev/sda";
4502     device[5] = devchar;
4503     int r;
4504     suppress_error = 0;
4505     r = guestfs_blockdev_setro (g, device);
4506     if (r == -1)
4507       return -1;
4508   }
4509   {
4510     char device[] = "/dev/sda";
4511     device[5] = devchar;
4512     int r;
4513     suppress_error = 0;
4514     r = guestfs_blockdev_getro (g, device);
4515     if (r == -1)
4516       return -1;
4517     if (!r) {
4518       fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
4519       return -1;
4520     }
4521   }
4522   return 0;
4523 }
4524
4525 static int test_blockdev_setrw_0 (void)
4526 {
4527   /* InitEmpty for blockdev_setrw (0) */
4528   {
4529     char device[] = "/dev/sda";
4530     device[5] = devchar;
4531     int r;
4532     suppress_error = 0;
4533     r = guestfs_blockdev_setrw (g, device);
4534     if (r == -1)
4535       return -1;
4536   }
4537   {
4538     int r;
4539     suppress_error = 0;
4540     r = guestfs_umount_all (g);
4541     if (r == -1)
4542       return -1;
4543   }
4544   {
4545     int r;
4546     suppress_error = 0;
4547     r = guestfs_lvm_remove_all (g);
4548     if (r == -1)
4549       return -1;
4550   }
4551   /* TestOutputFalse for blockdev_setrw (0) */
4552   {
4553     char device[] = "/dev/sda";
4554     device[5] = devchar;
4555     int r;
4556     suppress_error = 0;
4557     r = guestfs_blockdev_setrw (g, device);
4558     if (r == -1)
4559       return -1;
4560   }
4561   {
4562     char device[] = "/dev/sda";
4563     device[5] = devchar;
4564     int r;
4565     suppress_error = 0;
4566     r = guestfs_blockdev_getro (g, device);
4567     if (r == -1)
4568       return -1;
4569     if (r) {
4570       fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
4571       return -1;
4572     }
4573   }
4574   return 0;
4575 }
4576
4577 static int test_blockdev_setro_0 (void)
4578 {
4579   /* InitEmpty for blockdev_setro (0) */
4580   {
4581     char device[] = "/dev/sda";
4582     device[5] = devchar;
4583     int r;
4584     suppress_error = 0;
4585     r = guestfs_blockdev_setrw (g, device);
4586     if (r == -1)
4587       return -1;
4588   }
4589   {
4590     int r;
4591     suppress_error = 0;
4592     r = guestfs_umount_all (g);
4593     if (r == -1)
4594       return -1;
4595   }
4596   {
4597     int r;
4598     suppress_error = 0;
4599     r = guestfs_lvm_remove_all (g);
4600     if (r == -1)
4601       return -1;
4602   }
4603   /* TestOutputTrue for blockdev_setro (0) */
4604   {
4605     char device[] = "/dev/sda";
4606     device[5] = devchar;
4607     int r;
4608     suppress_error = 0;
4609     r = guestfs_blockdev_setro (g, device);
4610     if (r == -1)
4611       return -1;
4612   }
4613   {
4614     char device[] = "/dev/sda";
4615     device[5] = devchar;
4616     int r;
4617     suppress_error = 0;
4618     r = guestfs_blockdev_getro (g, device);
4619     if (r == -1)
4620       return -1;
4621     if (!r) {
4622       fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
4623       return -1;
4624     }
4625   }
4626   return 0;
4627 }
4628
4629 static int test_statvfs_0 (void)
4630 {
4631   /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
4632   {
4633     char device[] = "/dev/sda";
4634     device[5] = devchar;
4635     int r;
4636     suppress_error = 0;
4637     r = guestfs_blockdev_setrw (g, device);
4638     if (r == -1)
4639       return -1;
4640   }
4641   {
4642     int r;
4643     suppress_error = 0;
4644     r = guestfs_umount_all (g);
4645     if (r == -1)
4646       return -1;
4647   }
4648   {
4649     int r;
4650     suppress_error = 0;
4651     r = guestfs_lvm_remove_all (g);
4652     if (r == -1)
4653       return -1;
4654   }
4655   {
4656     char device[] = "/dev/sda";
4657     device[5] = devchar;
4658     char lines_0[] = ",";
4659     char *lines[] = {
4660       lines_0,
4661       NULL
4662     };
4663     int r;
4664     suppress_error = 0;
4665     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4666     if (r == -1)
4667       return -1;
4668   }
4669   {
4670     char fstype[] = "ext2";
4671     char device[] = "/dev/sda1";
4672     device[5] = devchar;
4673     int r;
4674     suppress_error = 0;
4675     r = guestfs_mkfs (g, fstype, device);
4676     if (r == -1)
4677       return -1;
4678   }
4679   {
4680     char device[] = "/dev/sda1";
4681     device[5] = devchar;
4682     char mountpoint[] = "/";
4683     int r;
4684     suppress_error = 0;
4685     r = guestfs_mount (g, device, mountpoint);
4686     if (r == -1)
4687       return -1;
4688   }
4689   /* TestOutputStruct for statvfs (0) */
4690   {
4691     char path[] = "/";
4692     struct guestfs_statvfs *r;
4693     suppress_error = 0;
4694     r = guestfs_statvfs (g, path);
4695     if (r == NULL)
4696       return -1;
4697     if (r->bfree != 487702) {
4698       fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
4699                (int) r->bfree);
4700       return -1;
4701     }
4702     if (r->blocks != 490020) {
4703       fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
4704                (int) r->blocks);
4705       return -1;
4706     }
4707     if (r->bsize != 1024) {
4708       fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
4709                (int) r->bsize);
4710       return -1;
4711     }
4712     free (r);
4713   }
4714   return 0;
4715 }
4716
4717 static int test_lstat_0 (void)
4718 {
4719   /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
4720   {
4721     char device[] = "/dev/sda";
4722     device[5] = devchar;
4723     int r;
4724     suppress_error = 0;
4725     r = guestfs_blockdev_setrw (g, device);
4726     if (r == -1)
4727       return -1;
4728   }
4729   {
4730     int r;
4731     suppress_error = 0;
4732     r = guestfs_umount_all (g);
4733     if (r == -1)
4734       return -1;
4735   }
4736   {
4737     int r;
4738     suppress_error = 0;
4739     r = guestfs_lvm_remove_all (g);
4740     if (r == -1)
4741       return -1;
4742   }
4743   {
4744     char device[] = "/dev/sda";
4745     device[5] = devchar;
4746     char lines_0[] = ",";
4747     char *lines[] = {
4748       lines_0,
4749       NULL
4750     };
4751     int r;
4752     suppress_error = 0;
4753     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4754     if (r == -1)
4755       return -1;
4756   }
4757   {
4758     char fstype[] = "ext2";
4759     char device[] = "/dev/sda1";
4760     device[5] = devchar;
4761     int r;
4762     suppress_error = 0;
4763     r = guestfs_mkfs (g, fstype, device);
4764     if (r == -1)
4765       return -1;
4766   }
4767   {
4768     char device[] = "/dev/sda1";
4769     device[5] = devchar;
4770     char mountpoint[] = "/";
4771     int r;
4772     suppress_error = 0;
4773     r = guestfs_mount (g, device, mountpoint);
4774     if (r == -1)
4775       return -1;
4776   }
4777   /* TestOutputStruct for lstat (0) */
4778   {
4779     char path[] = "/new";
4780     int r;
4781     suppress_error = 0;
4782     r = guestfs_touch (g, path);
4783     if (r == -1)
4784       return -1;
4785   }
4786   {
4787     char path[] = "/new";
4788     struct guestfs_stat *r;
4789     suppress_error = 0;
4790     r = guestfs_lstat (g, path);
4791     if (r == NULL)
4792       return -1;
4793     if (r->size != 0) {
4794       fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
4795                (int) r->size);
4796       return -1;
4797     }
4798     free (r);
4799   }
4800   return 0;
4801 }
4802
4803 static int test_stat_0 (void)
4804 {
4805   /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
4806   {
4807     char device[] = "/dev/sda";
4808     device[5] = devchar;
4809     int r;
4810     suppress_error = 0;
4811     r = guestfs_blockdev_setrw (g, device);
4812     if (r == -1)
4813       return -1;
4814   }
4815   {
4816     int r;
4817     suppress_error = 0;
4818     r = guestfs_umount_all (g);
4819     if (r == -1)
4820       return -1;
4821   }
4822   {
4823     int r;
4824     suppress_error = 0;
4825     r = guestfs_lvm_remove_all (g);
4826     if (r == -1)
4827       return -1;
4828   }
4829   {
4830     char device[] = "/dev/sda";
4831     device[5] = devchar;
4832     char lines_0[] = ",";
4833     char *lines[] = {
4834       lines_0,
4835       NULL
4836     };
4837     int r;
4838     suppress_error = 0;
4839     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4840     if (r == -1)
4841       return -1;
4842   }
4843   {
4844     char fstype[] = "ext2";
4845     char device[] = "/dev/sda1";
4846     device[5] = devchar;
4847     int r;
4848     suppress_error = 0;
4849     r = guestfs_mkfs (g, fstype, device);
4850     if (r == -1)
4851       return -1;
4852   }
4853   {
4854     char device[] = "/dev/sda1";
4855     device[5] = devchar;
4856     char mountpoint[] = "/";
4857     int r;
4858     suppress_error = 0;
4859     r = guestfs_mount (g, device, mountpoint);
4860     if (r == -1)
4861       return -1;
4862   }
4863   /* TestOutputStruct for stat (0) */
4864   {
4865     char path[] = "/new";
4866     int r;
4867     suppress_error = 0;
4868     r = guestfs_touch (g, path);
4869     if (r == -1)
4870       return -1;
4871   }
4872   {
4873     char path[] = "/new";
4874     struct guestfs_stat *r;
4875     suppress_error = 0;
4876     r = guestfs_stat (g, path);
4877     if (r == NULL)
4878       return -1;
4879     if (r->size != 0) {
4880       fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
4881                (int) r->size);
4882       return -1;
4883     }
4884     free (r);
4885   }
4886   return 0;
4887 }
4888
4889 static int test_file_0 (void)
4890 {
4891   /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
4892   {
4893     char device[] = "/dev/sda";
4894     device[5] = devchar;
4895     int r;
4896     suppress_error = 0;
4897     r = guestfs_blockdev_setrw (g, device);
4898     if (r == -1)
4899       return -1;
4900   }
4901   {
4902     int r;
4903     suppress_error = 0;
4904     r = guestfs_umount_all (g);
4905     if (r == -1)
4906       return -1;
4907   }
4908   {
4909     int r;
4910     suppress_error = 0;
4911     r = guestfs_lvm_remove_all (g);
4912     if (r == -1)
4913       return -1;
4914   }
4915   {
4916     char device[] = "/dev/sda";
4917     device[5] = devchar;
4918     char lines_0[] = ",";
4919     char *lines[] = {
4920       lines_0,
4921       NULL
4922     };
4923     int r;
4924     suppress_error = 0;
4925     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4926     if (r == -1)
4927       return -1;
4928   }
4929   {
4930     char fstype[] = "ext2";
4931     char device[] = "/dev/sda1";
4932     device[5] = devchar;
4933     int r;
4934     suppress_error = 0;
4935     r = guestfs_mkfs (g, fstype, device);
4936     if (r == -1)
4937       return -1;
4938   }
4939   {
4940     char device[] = "/dev/sda1";
4941     device[5] = devchar;
4942     char mountpoint[] = "/";
4943     int r;
4944     suppress_error = 0;
4945     r = guestfs_mount (g, device, mountpoint);
4946     if (r == -1)
4947       return -1;
4948   }
4949   /* TestOutput for file (0) */
4950   char expected[] = "empty";
4951   {
4952     char path[] = "/new";
4953     int r;
4954     suppress_error = 0;
4955     r = guestfs_touch (g, path);
4956     if (r == -1)
4957       return -1;
4958   }
4959   {
4960     char path[] = "/new";
4961     char *r;
4962     suppress_error = 0;
4963     r = guestfs_file (g, path);
4964     if (r == NULL)
4965       return -1;
4966     if (strcmp (r, expected) != 0) {
4967       fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
4968       return -1;
4969     }
4970     free (r);
4971   }
4972   return 0;
4973 }
4974
4975 static int test_file_1 (void)
4976 {
4977   /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
4978   {
4979     char device[] = "/dev/sda";
4980     device[5] = devchar;
4981     int r;
4982     suppress_error = 0;
4983     r = guestfs_blockdev_setrw (g, device);
4984     if (r == -1)
4985       return -1;
4986   }
4987   {
4988     int r;
4989     suppress_error = 0;
4990     r = guestfs_umount_all (g);
4991     if (r == -1)
4992       return -1;
4993   }
4994   {
4995     int r;
4996     suppress_error = 0;
4997     r = guestfs_lvm_remove_all (g);
4998     if (r == -1)
4999       return -1;
5000   }
5001   {
5002     char device[] = "/dev/sda";
5003     device[5] = devchar;
5004     char lines_0[] = ",";
5005     char *lines[] = {
5006       lines_0,
5007       NULL
5008     };
5009     int r;
5010     suppress_error = 0;
5011     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5012     if (r == -1)
5013       return -1;
5014   }
5015   {
5016     char fstype[] = "ext2";
5017     char device[] = "/dev/sda1";
5018     device[5] = devchar;
5019     int r;
5020     suppress_error = 0;
5021     r = guestfs_mkfs (g, fstype, device);
5022     if (r == -1)
5023       return -1;
5024   }
5025   {
5026     char device[] = "/dev/sda1";
5027     device[5] = devchar;
5028     char mountpoint[] = "/";
5029     int r;
5030     suppress_error = 0;
5031     r = guestfs_mount (g, device, mountpoint);
5032     if (r == -1)
5033       return -1;
5034   }
5035   /* TestOutput for file (1) */
5036   char expected[] = "ASCII text";
5037   {
5038     char path[] = "/new";
5039     char content[] = "some content\n";
5040     int r;
5041     suppress_error = 0;
5042     r = guestfs_write_file (g, path, content, 0);
5043     if (r == -1)
5044       return -1;
5045   }
5046   {
5047     char path[] = "/new";
5048     char *r;
5049     suppress_error = 0;
5050     r = guestfs_file (g, path);
5051     if (r == NULL)
5052       return -1;
5053     if (strcmp (r, expected) != 0) {
5054       fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5055       return -1;
5056     }
5057     free (r);
5058   }
5059   return 0;
5060 }
5061
5062 static int test_file_2 (void)
5063 {
5064   /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
5065   {
5066     char device[] = "/dev/sda";
5067     device[5] = devchar;
5068     int r;
5069     suppress_error = 0;
5070     r = guestfs_blockdev_setrw (g, device);
5071     if (r == -1)
5072       return -1;
5073   }
5074   {
5075     int r;
5076     suppress_error = 0;
5077     r = guestfs_umount_all (g);
5078     if (r == -1)
5079       return -1;
5080   }
5081   {
5082     int r;
5083     suppress_error = 0;
5084     r = guestfs_lvm_remove_all (g);
5085     if (r == -1)
5086       return -1;
5087   }
5088   {
5089     char device[] = "/dev/sda";
5090     device[5] = devchar;
5091     char lines_0[] = ",";
5092     char *lines[] = {
5093       lines_0,
5094       NULL
5095     };
5096     int r;
5097     suppress_error = 0;
5098     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5099     if (r == -1)
5100       return -1;
5101   }
5102   {
5103     char fstype[] = "ext2";
5104     char device[] = "/dev/sda1";
5105     device[5] = devchar;
5106     int r;
5107     suppress_error = 0;
5108     r = guestfs_mkfs (g, fstype, device);
5109     if (r == -1)
5110       return -1;
5111   }
5112   {
5113     char device[] = "/dev/sda1";
5114     device[5] = devchar;
5115     char mountpoint[] = "/";
5116     int r;
5117     suppress_error = 0;
5118     r = guestfs_mount (g, device, mountpoint);
5119     if (r == -1)
5120       return -1;
5121   }
5122   /* TestLastFail for file (2) */
5123   {
5124     char path[] = "/nofile";
5125     char *r;
5126     suppress_error = 1;
5127     r = guestfs_file (g, path);
5128     if (r != NULL)
5129       return -1;
5130     free (r);
5131   }
5132   return 0;
5133 }
5134
5135 static int test_umount_all_0 (void)
5136 {
5137   /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
5138   {
5139     char device[] = "/dev/sda";
5140     device[5] = devchar;
5141     int r;
5142     suppress_error = 0;
5143     r = guestfs_blockdev_setrw (g, device);
5144     if (r == -1)
5145       return -1;
5146   }
5147   {
5148     int r;
5149     suppress_error = 0;
5150     r = guestfs_umount_all (g);
5151     if (r == -1)
5152       return -1;
5153   }
5154   {
5155     int r;
5156     suppress_error = 0;
5157     r = guestfs_lvm_remove_all (g);
5158     if (r == -1)
5159       return -1;
5160   }
5161   {
5162     char device[] = "/dev/sda";
5163     device[5] = devchar;
5164     char lines_0[] = ",";
5165     char *lines[] = {
5166       lines_0,
5167       NULL
5168     };
5169     int r;
5170     suppress_error = 0;
5171     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5172     if (r == -1)
5173       return -1;
5174   }
5175   {
5176     char fstype[] = "ext2";
5177     char device[] = "/dev/sda1";
5178     device[5] = devchar;
5179     int r;
5180     suppress_error = 0;
5181     r = guestfs_mkfs (g, fstype, device);
5182     if (r == -1)
5183       return -1;
5184   }
5185   {
5186     char device[] = "/dev/sda1";
5187     device[5] = devchar;
5188     char mountpoint[] = "/";
5189     int r;
5190     suppress_error = 0;
5191     r = guestfs_mount (g, device, mountpoint);
5192     if (r == -1)
5193       return -1;
5194   }
5195   /* TestOutputList for umount_all (0) */
5196   {
5197     int r;
5198     suppress_error = 0;
5199     r = guestfs_umount_all (g);
5200     if (r == -1)
5201       return -1;
5202   }
5203   {
5204     char **r;
5205     int i;
5206     suppress_error = 0;
5207     r = guestfs_mounts (g);
5208     if (r == NULL)
5209       return -1;
5210     if (r[0] != NULL) {
5211       fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
5212       print_strings (r);
5213       return -1;
5214     }
5215     for (i = 0; r[i] != NULL; ++i)
5216       free (r[i]);
5217     free (r);
5218   }
5219   return 0;
5220 }
5221
5222 static int test_umount_all_1 (void)
5223 {
5224   /* InitEmpty for umount_all (1) */
5225   {
5226     char device[] = "/dev/sda";
5227     device[5] = devchar;
5228     int r;
5229     suppress_error = 0;
5230     r = guestfs_blockdev_setrw (g, device);
5231     if (r == -1)
5232       return -1;
5233   }
5234   {
5235     int r;
5236     suppress_error = 0;
5237     r = guestfs_umount_all (g);
5238     if (r == -1)
5239       return -1;
5240   }
5241   {
5242     int r;
5243     suppress_error = 0;
5244     r = guestfs_lvm_remove_all (g);
5245     if (r == -1)
5246       return -1;
5247   }
5248   /* TestOutputList for umount_all (1) */
5249   {
5250     char device[] = "/dev/sda";
5251     device[5] = devchar;
5252     char lines_0[] = ",10";
5253     char lines_1[] = ",20";
5254     char lines_2[] = ",";
5255     char *lines[] = {
5256       lines_0,
5257       lines_1,
5258       lines_2,
5259       NULL
5260     };
5261     int r;
5262     suppress_error = 0;
5263     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5264     if (r == -1)
5265       return -1;
5266   }
5267   {
5268     char fstype[] = "ext2";
5269     char device[] = "/dev/sda1";
5270     device[5] = devchar;
5271     int r;
5272     suppress_error = 0;
5273     r = guestfs_mkfs (g, fstype, device);
5274     if (r == -1)
5275       return -1;
5276   }
5277   {
5278     char fstype[] = "ext2";
5279     char device[] = "/dev/sda2";
5280     device[5] = devchar;
5281     int r;
5282     suppress_error = 0;
5283     r = guestfs_mkfs (g, fstype, device);
5284     if (r == -1)
5285       return -1;
5286   }
5287   {
5288     char fstype[] = "ext2";
5289     char device[] = "/dev/sda3";
5290     device[5] = devchar;
5291     int r;
5292     suppress_error = 0;
5293     r = guestfs_mkfs (g, fstype, device);
5294     if (r == -1)
5295       return -1;
5296   }
5297   {
5298     char device[] = "/dev/sda1";
5299     device[5] = devchar;
5300     char mountpoint[] = "/";
5301     int r;
5302     suppress_error = 0;
5303     r = guestfs_mount (g, device, mountpoint);
5304     if (r == -1)
5305       return -1;
5306   }
5307   {
5308     char path[] = "/mp1";
5309     int r;
5310     suppress_error = 0;
5311     r = guestfs_mkdir (g, path);
5312     if (r == -1)
5313       return -1;
5314   }
5315   {
5316     char device[] = "/dev/sda2";
5317     device[5] = devchar;
5318     char mountpoint[] = "/mp1";
5319     int r;
5320     suppress_error = 0;
5321     r = guestfs_mount (g, device, mountpoint);
5322     if (r == -1)
5323       return -1;
5324   }
5325   {
5326     char path[] = "/mp1/mp2";
5327     int r;
5328     suppress_error = 0;
5329     r = guestfs_mkdir (g, path);
5330     if (r == -1)
5331       return -1;
5332   }
5333   {
5334     char device[] = "/dev/sda3";
5335     device[5] = devchar;
5336     char mountpoint[] = "/mp1/mp2";
5337     int r;
5338     suppress_error = 0;
5339     r = guestfs_mount (g, device, mountpoint);
5340     if (r == -1)
5341       return -1;
5342   }
5343   {
5344     char path[] = "/mp1/mp2/mp3";
5345     int r;
5346     suppress_error = 0;
5347     r = guestfs_mkdir (g, path);
5348     if (r == -1)
5349       return -1;
5350   }
5351   {
5352     int r;
5353     suppress_error = 0;
5354     r = guestfs_umount_all (g);
5355     if (r == -1)
5356       return -1;
5357   }
5358   {
5359     char **r;
5360     int i;
5361     suppress_error = 0;
5362     r = guestfs_mounts (g);
5363     if (r == NULL)
5364       return -1;
5365     if (r[0] != NULL) {
5366       fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
5367       print_strings (r);
5368       return -1;
5369     }
5370     for (i = 0; r[i] != NULL; ++i)
5371       free (r[i]);
5372     free (r);
5373   }
5374   return 0;
5375 }
5376
5377 static int test_mounts_0 (void)
5378 {
5379   /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
5380   {
5381     char device[] = "/dev/sda";
5382     device[5] = devchar;
5383     int r;
5384     suppress_error = 0;
5385     r = guestfs_blockdev_setrw (g, device);
5386     if (r == -1)
5387       return -1;
5388   }
5389   {
5390     int r;
5391     suppress_error = 0;
5392     r = guestfs_umount_all (g);
5393     if (r == -1)
5394       return -1;
5395   }
5396   {
5397     int r;
5398     suppress_error = 0;
5399     r = guestfs_lvm_remove_all (g);
5400     if (r == -1)
5401       return -1;
5402   }
5403   {
5404     char device[] = "/dev/sda";
5405     device[5] = devchar;
5406     char lines_0[] = ",";
5407     char *lines[] = {
5408       lines_0,
5409       NULL
5410     };
5411     int r;
5412     suppress_error = 0;
5413     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5414     if (r == -1)
5415       return -1;
5416   }
5417   {
5418     char fstype[] = "ext2";
5419     char device[] = "/dev/sda1";
5420     device[5] = devchar;
5421     int r;
5422     suppress_error = 0;
5423     r = guestfs_mkfs (g, fstype, device);
5424     if (r == -1)
5425       return -1;
5426   }
5427   {
5428     char device[] = "/dev/sda1";
5429     device[5] = devchar;
5430     char mountpoint[] = "/";
5431     int r;
5432     suppress_error = 0;
5433     r = guestfs_mount (g, device, mountpoint);
5434     if (r == -1)
5435       return -1;
5436   }
5437   /* TestOutputList for mounts (0) */
5438   {
5439     char **r;
5440     int i;
5441     suppress_error = 0;
5442     r = guestfs_mounts (g);
5443     if (r == NULL)
5444       return -1;
5445     if (!r[0]) {
5446       fprintf (stderr, "test_mounts_0: short list returned from command\n");
5447       print_strings (r);
5448       return -1;
5449     }
5450     {
5451       char expected[] = "/dev/sda1";
5452       expected[5] = devchar;
5453       if (strcmp (r[0], expected) != 0) {
5454         fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5455         return -1;
5456       }
5457     }
5458     if (r[1] != NULL) {
5459       fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
5460       print_strings (r);
5461       return -1;
5462     }
5463     for (i = 0; r[i] != NULL; ++i)
5464       free (r[i]);
5465     free (r);
5466   }
5467   return 0;
5468 }
5469
5470 static int test_umount_0 (void)
5471 {
5472   /* InitEmpty for umount (0) */
5473   {
5474     char device[] = "/dev/sda";
5475     device[5] = devchar;
5476     int r;
5477     suppress_error = 0;
5478     r = guestfs_blockdev_setrw (g, device);
5479     if (r == -1)
5480       return -1;
5481   }
5482   {
5483     int r;
5484     suppress_error = 0;
5485     r = guestfs_umount_all (g);
5486     if (r == -1)
5487       return -1;
5488   }
5489   {
5490     int r;
5491     suppress_error = 0;
5492     r = guestfs_lvm_remove_all (g);
5493     if (r == -1)
5494       return -1;
5495   }
5496   /* TestOutputList for umount (0) */
5497   {
5498     char device[] = "/dev/sda";
5499     device[5] = devchar;
5500     char lines_0[] = ",";
5501     char *lines[] = {
5502       lines_0,
5503       NULL
5504     };
5505     int r;
5506     suppress_error = 0;
5507     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5508     if (r == -1)
5509       return -1;
5510   }
5511   {
5512     char fstype[] = "ext2";
5513     char device[] = "/dev/sda1";
5514     device[5] = devchar;
5515     int r;
5516     suppress_error = 0;
5517     r = guestfs_mkfs (g, fstype, device);
5518     if (r == -1)
5519       return -1;
5520   }
5521   {
5522     char device[] = "/dev/sda1";
5523     device[5] = devchar;
5524     char mountpoint[] = "/";
5525     int r;
5526     suppress_error = 0;
5527     r = guestfs_mount (g, device, mountpoint);
5528     if (r == -1)
5529       return -1;
5530   }
5531   {
5532     char **r;
5533     int i;
5534     suppress_error = 0;
5535     r = guestfs_mounts (g);
5536     if (r == NULL)
5537       return -1;
5538     if (!r[0]) {
5539       fprintf (stderr, "test_umount_0: short list returned from command\n");
5540       print_strings (r);
5541       return -1;
5542     }
5543     {
5544       char expected[] = "/dev/sda1";
5545       expected[5] = devchar;
5546       if (strcmp (r[0], expected) != 0) {
5547         fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5548         return -1;
5549       }
5550     }
5551     if (r[1] != NULL) {
5552       fprintf (stderr, "test_umount_0: extra elements returned from command\n");
5553       print_strings (r);
5554       return -1;
5555     }
5556     for (i = 0; r[i] != NULL; ++i)
5557       free (r[i]);
5558     free (r);
5559   }
5560   return 0;
5561 }
5562
5563 static int test_umount_1 (void)
5564 {
5565   /* InitEmpty for umount (1) */
5566   {
5567     char device[] = "/dev/sda";
5568     device[5] = devchar;
5569     int r;
5570     suppress_error = 0;
5571     r = guestfs_blockdev_setrw (g, device);
5572     if (r == -1)
5573       return -1;
5574   }
5575   {
5576     int r;
5577     suppress_error = 0;
5578     r = guestfs_umount_all (g);
5579     if (r == -1)
5580       return -1;
5581   }
5582   {
5583     int r;
5584     suppress_error = 0;
5585     r = guestfs_lvm_remove_all (g);
5586     if (r == -1)
5587       return -1;
5588   }
5589   /* TestOutputList for umount (1) */
5590   {
5591     char device[] = "/dev/sda";
5592     device[5] = devchar;
5593     char lines_0[] = ",";
5594     char *lines[] = {
5595       lines_0,
5596       NULL
5597     };
5598     int r;
5599     suppress_error = 0;
5600     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5601     if (r == -1)
5602       return -1;
5603   }
5604   {
5605     char fstype[] = "ext2";
5606     char device[] = "/dev/sda1";
5607     device[5] = devchar;
5608     int r;
5609     suppress_error = 0;
5610     r = guestfs_mkfs (g, fstype, device);
5611     if (r == -1)
5612       return -1;
5613   }
5614   {
5615     char device[] = "/dev/sda1";
5616     device[5] = devchar;
5617     char mountpoint[] = "/";
5618     int r;
5619     suppress_error = 0;
5620     r = guestfs_mount (g, device, mountpoint);
5621     if (r == -1)
5622       return -1;
5623   }
5624   {
5625     char pathordevice[] = "/";
5626     int r;
5627     suppress_error = 0;
5628     r = guestfs_umount (g, pathordevice);
5629     if (r == -1)
5630       return -1;
5631   }
5632   {
5633     char **r;
5634     int i;
5635     suppress_error = 0;
5636     r = guestfs_mounts (g);
5637     if (r == NULL)
5638       return -1;
5639     if (r[0] != NULL) {
5640       fprintf (stderr, "test_umount_1: extra elements returned from command\n");
5641       print_strings (r);
5642       return -1;
5643     }
5644     for (i = 0; r[i] != NULL; ++i)
5645       free (r[i]);
5646     free (r);
5647   }
5648   return 0;
5649 }
5650
5651 static int test_write_file_0 (void)
5652 {
5653   /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
5654   {
5655     char device[] = "/dev/sda";
5656     device[5] = devchar;
5657     int r;
5658     suppress_error = 0;
5659     r = guestfs_blockdev_setrw (g, device);
5660     if (r == -1)
5661       return -1;
5662   }
5663   {
5664     int r;
5665     suppress_error = 0;
5666     r = guestfs_umount_all (g);
5667     if (r == -1)
5668       return -1;
5669   }
5670   {
5671     int r;
5672     suppress_error = 0;
5673     r = guestfs_lvm_remove_all (g);
5674     if (r == -1)
5675       return -1;
5676   }
5677   {
5678     char device[] = "/dev/sda";
5679     device[5] = devchar;
5680     char lines_0[] = ",";
5681     char *lines[] = {
5682       lines_0,
5683       NULL
5684     };
5685     int r;
5686     suppress_error = 0;
5687     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5688     if (r == -1)
5689       return -1;
5690   }
5691   {
5692     char fstype[] = "ext2";
5693     char device[] = "/dev/sda1";
5694     device[5] = devchar;
5695     int r;
5696     suppress_error = 0;
5697     r = guestfs_mkfs (g, fstype, device);
5698     if (r == -1)
5699       return -1;
5700   }
5701   {
5702     char device[] = "/dev/sda1";
5703     device[5] = devchar;
5704     char mountpoint[] = "/";
5705     int r;
5706     suppress_error = 0;
5707     r = guestfs_mount (g, device, mountpoint);
5708     if (r == -1)
5709       return -1;
5710   }
5711   /* TestOutput for write_file (0) */
5712   char expected[] = "new file contents";
5713   {
5714     char path[] = "/new";
5715     char content[] = "new file contents";
5716     int r;
5717     suppress_error = 0;
5718     r = guestfs_write_file (g, path, content, 0);
5719     if (r == -1)
5720       return -1;
5721   }
5722   {
5723     char path[] = "/new";
5724     char *r;
5725     suppress_error = 0;
5726     r = guestfs_cat (g, path);
5727     if (r == NULL)
5728       return -1;
5729     if (strcmp (r, expected) != 0) {
5730       fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
5731       return -1;
5732     }
5733     free (r);
5734   }
5735   return 0;
5736 }
5737
5738 static int test_write_file_1 (void)
5739 {
5740   /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
5741   {
5742     char device[] = "/dev/sda";
5743     device[5] = devchar;
5744     int r;
5745     suppress_error = 0;
5746     r = guestfs_blockdev_setrw (g, device);
5747     if (r == -1)
5748       return -1;
5749   }
5750   {
5751     int r;
5752     suppress_error = 0;
5753     r = guestfs_umount_all (g);
5754     if (r == -1)
5755       return -1;
5756   }
5757   {
5758     int r;
5759     suppress_error = 0;
5760     r = guestfs_lvm_remove_all (g);
5761     if (r == -1)
5762       return -1;
5763   }
5764   {
5765     char device[] = "/dev/sda";
5766     device[5] = devchar;
5767     char lines_0[] = ",";
5768     char *lines[] = {
5769       lines_0,
5770       NULL
5771     };
5772     int r;
5773     suppress_error = 0;
5774     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5775     if (r == -1)
5776       return -1;
5777   }
5778   {
5779     char fstype[] = "ext2";
5780     char device[] = "/dev/sda1";
5781     device[5] = devchar;
5782     int r;
5783     suppress_error = 0;
5784     r = guestfs_mkfs (g, fstype, device);
5785     if (r == -1)
5786       return -1;
5787   }
5788   {
5789     char device[] = "/dev/sda1";
5790     device[5] = devchar;
5791     char mountpoint[] = "/";
5792     int r;
5793     suppress_error = 0;
5794     r = guestfs_mount (g, device, mountpoint);
5795     if (r == -1)
5796       return -1;
5797   }
5798   /* TestOutput for write_file (1) */
5799   char expected[] = "\nnew file contents\n";
5800   {
5801     char path[] = "/new";
5802     char content[] = "\nnew file contents\n";
5803     int r;
5804     suppress_error = 0;
5805     r = guestfs_write_file (g, path, content, 0);
5806     if (r == -1)
5807       return -1;
5808   }
5809   {
5810     char path[] = "/new";
5811     char *r;
5812     suppress_error = 0;
5813     r = guestfs_cat (g, path);
5814     if (r == NULL)
5815       return -1;
5816     if (strcmp (r, expected) != 0) {
5817       fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5818       return -1;
5819     }
5820     free (r);
5821   }
5822   return 0;
5823 }
5824
5825 static int test_write_file_2 (void)
5826 {
5827   /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
5828   {
5829     char device[] = "/dev/sda";
5830     device[5] = devchar;
5831     int r;
5832     suppress_error = 0;
5833     r = guestfs_blockdev_setrw (g, device);
5834     if (r == -1)
5835       return -1;
5836   }
5837   {
5838     int r;
5839     suppress_error = 0;
5840     r = guestfs_umount_all (g);
5841     if (r == -1)
5842       return -1;
5843   }
5844   {
5845     int r;
5846     suppress_error = 0;
5847     r = guestfs_lvm_remove_all (g);
5848     if (r == -1)
5849       return -1;
5850   }
5851   {
5852     char device[] = "/dev/sda";
5853     device[5] = devchar;
5854     char lines_0[] = ",";
5855     char *lines[] = {
5856       lines_0,
5857       NULL
5858     };
5859     int r;
5860     suppress_error = 0;
5861     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5862     if (r == -1)
5863       return -1;
5864   }
5865   {
5866     char fstype[] = "ext2";
5867     char device[] = "/dev/sda1";
5868     device[5] = devchar;
5869     int r;
5870     suppress_error = 0;
5871     r = guestfs_mkfs (g, fstype, device);
5872     if (r == -1)
5873       return -1;
5874   }
5875   {
5876     char device[] = "/dev/sda1";
5877     device[5] = devchar;
5878     char mountpoint[] = "/";
5879     int r;
5880     suppress_error = 0;
5881     r = guestfs_mount (g, device, mountpoint);
5882     if (r == -1)
5883       return -1;
5884   }
5885   /* TestOutput for write_file (2) */
5886   char expected[] = "\n\n";
5887   {
5888     char path[] = "/new";
5889     char content[] = "\n\n";
5890     int r;
5891     suppress_error = 0;
5892     r = guestfs_write_file (g, path, content, 0);
5893     if (r == -1)
5894       return -1;
5895   }
5896   {
5897     char path[] = "/new";
5898     char *r;
5899     suppress_error = 0;
5900     r = guestfs_cat (g, path);
5901     if (r == NULL)
5902       return -1;
5903     if (strcmp (r, expected) != 0) {
5904       fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
5905       return -1;
5906     }
5907     free (r);
5908   }
5909   return 0;
5910 }
5911
5912 static int test_write_file_3 (void)
5913 {
5914   /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
5915   {
5916     char device[] = "/dev/sda";
5917     device[5] = devchar;
5918     int r;
5919     suppress_error = 0;
5920     r = guestfs_blockdev_setrw (g, device);
5921     if (r == -1)
5922       return -1;
5923   }
5924   {
5925     int r;
5926     suppress_error = 0;
5927     r = guestfs_umount_all (g);
5928     if (r == -1)
5929       return -1;
5930   }
5931   {
5932     int r;
5933     suppress_error = 0;
5934     r = guestfs_lvm_remove_all (g);
5935     if (r == -1)
5936       return -1;
5937   }
5938   {
5939     char device[] = "/dev/sda";
5940     device[5] = devchar;
5941     char lines_0[] = ",";
5942     char *lines[] = {
5943       lines_0,
5944       NULL
5945     };
5946     int r;
5947     suppress_error = 0;
5948     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5949     if (r == -1)
5950       return -1;
5951   }
5952   {
5953     char fstype[] = "ext2";
5954     char device[] = "/dev/sda1";
5955     device[5] = devchar;
5956     int r;
5957     suppress_error = 0;
5958     r = guestfs_mkfs (g, fstype, device);
5959     if (r == -1)
5960       return -1;
5961   }
5962   {
5963     char device[] = "/dev/sda1";
5964     device[5] = devchar;
5965     char mountpoint[] = "/";
5966     int r;
5967     suppress_error = 0;
5968     r = guestfs_mount (g, device, mountpoint);
5969     if (r == -1)
5970       return -1;
5971   }
5972   /* TestOutput for write_file (3) */
5973   char expected[] = "";
5974   {
5975     char path[] = "/new";
5976     char content[] = "";
5977     int r;
5978     suppress_error = 0;
5979     r = guestfs_write_file (g, path, content, 0);
5980     if (r == -1)
5981       return -1;
5982   }
5983   {
5984     char path[] = "/new";
5985     char *r;
5986     suppress_error = 0;
5987     r = guestfs_cat (g, path);
5988     if (r == NULL)
5989       return -1;
5990     if (strcmp (r, expected) != 0) {
5991       fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
5992       return -1;
5993     }
5994     free (r);
5995   }
5996   return 0;
5997 }
5998
5999 static int test_write_file_4 (void)
6000 {
6001   /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
6002   {
6003     char device[] = "/dev/sda";
6004     device[5] = devchar;
6005     int r;
6006     suppress_error = 0;
6007     r = guestfs_blockdev_setrw (g, device);
6008     if (r == -1)
6009       return -1;
6010   }
6011   {
6012     int r;
6013     suppress_error = 0;
6014     r = guestfs_umount_all (g);
6015     if (r == -1)
6016       return -1;
6017   }
6018   {
6019     int r;
6020     suppress_error = 0;
6021     r = guestfs_lvm_remove_all (g);
6022     if (r == -1)
6023       return -1;
6024   }
6025   {
6026     char device[] = "/dev/sda";
6027     device[5] = devchar;
6028     char lines_0[] = ",";
6029     char *lines[] = {
6030       lines_0,
6031       NULL
6032     };
6033     int r;
6034     suppress_error = 0;
6035     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6036     if (r == -1)
6037       return -1;
6038   }
6039   {
6040     char fstype[] = "ext2";
6041     char device[] = "/dev/sda1";
6042     device[5] = devchar;
6043     int r;
6044     suppress_error = 0;
6045     r = guestfs_mkfs (g, fstype, device);
6046     if (r == -1)
6047       return -1;
6048   }
6049   {
6050     char device[] = "/dev/sda1";
6051     device[5] = devchar;
6052     char mountpoint[] = "/";
6053     int r;
6054     suppress_error = 0;
6055     r = guestfs_mount (g, device, mountpoint);
6056     if (r == -1)
6057       return -1;
6058   }
6059   /* TestOutput for write_file (4) */
6060   char expected[] = "\n\n\n";
6061   {
6062     char path[] = "/new";
6063     char content[] = "\n\n\n";
6064     int r;
6065     suppress_error = 0;
6066     r = guestfs_write_file (g, path, content, 0);
6067     if (r == -1)
6068       return -1;
6069   }
6070   {
6071     char path[] = "/new";
6072     char *r;
6073     suppress_error = 0;
6074     r = guestfs_cat (g, path);
6075     if (r == NULL)
6076       return -1;
6077     if (strcmp (r, expected) != 0) {
6078       fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
6079       return -1;
6080     }
6081     free (r);
6082   }
6083   return 0;
6084 }
6085
6086 static int test_write_file_5 (void)
6087 {
6088   /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
6089   {
6090     char device[] = "/dev/sda";
6091     device[5] = devchar;
6092     int r;
6093     suppress_error = 0;
6094     r = guestfs_blockdev_setrw (g, device);
6095     if (r == -1)
6096       return -1;
6097   }
6098   {
6099     int r;
6100     suppress_error = 0;
6101     r = guestfs_umount_all (g);
6102     if (r == -1)
6103       return -1;
6104   }
6105   {
6106     int r;
6107     suppress_error = 0;
6108     r = guestfs_lvm_remove_all (g);
6109     if (r == -1)
6110       return -1;
6111   }
6112   {
6113     char device[] = "/dev/sda";
6114     device[5] = devchar;
6115     char lines_0[] = ",";
6116     char *lines[] = {
6117       lines_0,
6118       NULL
6119     };
6120     int r;
6121     suppress_error = 0;
6122     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6123     if (r == -1)
6124       return -1;
6125   }
6126   {
6127     char fstype[] = "ext2";
6128     char device[] = "/dev/sda1";
6129     device[5] = devchar;
6130     int r;
6131     suppress_error = 0;
6132     r = guestfs_mkfs (g, fstype, device);
6133     if (r == -1)
6134       return -1;
6135   }
6136   {
6137     char device[] = "/dev/sda1";
6138     device[5] = devchar;
6139     char mountpoint[] = "/";
6140     int r;
6141     suppress_error = 0;
6142     r = guestfs_mount (g, device, mountpoint);
6143     if (r == -1)
6144       return -1;
6145   }
6146   /* TestOutput for write_file (5) */
6147   char expected[] = "\n";
6148   {
6149     char path[] = "/new";
6150     char content[] = "\n";
6151     int r;
6152     suppress_error = 0;
6153     r = guestfs_write_file (g, path, content, 0);
6154     if (r == -1)
6155       return -1;
6156   }
6157   {
6158     char path[] = "/new";
6159     char *r;
6160     suppress_error = 0;
6161     r = guestfs_cat (g, path);
6162     if (r == NULL)
6163       return -1;
6164     if (strcmp (r, expected) != 0) {
6165       fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
6166       return -1;
6167     }
6168     free (r);
6169   }
6170   return 0;
6171 }
6172
6173 static int test_mkfs_0 (void)
6174 {
6175   /* InitEmpty for mkfs (0) */
6176   {
6177     char device[] = "/dev/sda";
6178     device[5] = devchar;
6179     int r;
6180     suppress_error = 0;
6181     r = guestfs_blockdev_setrw (g, device);
6182     if (r == -1)
6183       return -1;
6184   }
6185   {
6186     int r;
6187     suppress_error = 0;
6188     r = guestfs_umount_all (g);
6189     if (r == -1)
6190       return -1;
6191   }
6192   {
6193     int r;
6194     suppress_error = 0;
6195     r = guestfs_lvm_remove_all (g);
6196     if (r == -1)
6197       return -1;
6198   }
6199   /* TestOutput for mkfs (0) */
6200   char expected[] = "new file contents";
6201   {
6202     char device[] = "/dev/sda";
6203     device[5] = devchar;
6204     char lines_0[] = ",";
6205     char *lines[] = {
6206       lines_0,
6207       NULL
6208     };
6209     int r;
6210     suppress_error = 0;
6211     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6212     if (r == -1)
6213       return -1;
6214   }
6215   {
6216     char fstype[] = "ext2";
6217     char device[] = "/dev/sda1";
6218     device[5] = devchar;
6219     int r;
6220     suppress_error = 0;
6221     r = guestfs_mkfs (g, fstype, device);
6222     if (r == -1)
6223       return -1;
6224   }
6225   {
6226     char device[] = "/dev/sda1";
6227     device[5] = devchar;
6228     char mountpoint[] = "/";
6229     int r;
6230     suppress_error = 0;
6231     r = guestfs_mount (g, device, mountpoint);
6232     if (r == -1)
6233       return -1;
6234   }
6235   {
6236     char path[] = "/new";
6237     char content[] = "new file contents";
6238     int r;
6239     suppress_error = 0;
6240     r = guestfs_write_file (g, path, content, 0);
6241     if (r == -1)
6242       return -1;
6243   }
6244   {
6245     char path[] = "/new";
6246     char *r;
6247     suppress_error = 0;
6248     r = guestfs_cat (g, path);
6249     if (r == NULL)
6250       return -1;
6251     if (strcmp (r, expected) != 0) {
6252       fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
6253       return -1;
6254     }
6255     free (r);
6256   }
6257   return 0;
6258 }
6259
6260 static int test_lvcreate_0 (void)
6261 {
6262   /* InitEmpty for lvcreate (0) */
6263   {
6264     char device[] = "/dev/sda";
6265     device[5] = devchar;
6266     int r;
6267     suppress_error = 0;
6268     r = guestfs_blockdev_setrw (g, device);
6269     if (r == -1)
6270       return -1;
6271   }
6272   {
6273     int r;
6274     suppress_error = 0;
6275     r = guestfs_umount_all (g);
6276     if (r == -1)
6277       return -1;
6278   }
6279   {
6280     int r;
6281     suppress_error = 0;
6282     r = guestfs_lvm_remove_all (g);
6283     if (r == -1)
6284       return -1;
6285   }
6286   /* TestOutputList for lvcreate (0) */
6287   {
6288     char device[] = "/dev/sda";
6289     device[5] = devchar;
6290     char lines_0[] = ",10";
6291     char lines_1[] = ",20";
6292     char lines_2[] = ",";
6293     char *lines[] = {
6294       lines_0,
6295       lines_1,
6296       lines_2,
6297       NULL
6298     };
6299     int r;
6300     suppress_error = 0;
6301     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6302     if (r == -1)
6303       return -1;
6304   }
6305   {
6306     char device[] = "/dev/sda1";
6307     device[5] = devchar;
6308     int r;
6309     suppress_error = 0;
6310     r = guestfs_pvcreate (g, device);
6311     if (r == -1)
6312       return -1;
6313   }
6314   {
6315     char device[] = "/dev/sda2";
6316     device[5] = devchar;
6317     int r;
6318     suppress_error = 0;
6319     r = guestfs_pvcreate (g, device);
6320     if (r == -1)
6321       return -1;
6322   }
6323   {
6324     char device[] = "/dev/sda3";
6325     device[5] = devchar;
6326     int r;
6327     suppress_error = 0;
6328     r = guestfs_pvcreate (g, device);
6329     if (r == -1)
6330       return -1;
6331   }
6332   {
6333     char volgroup[] = "VG1";
6334     char physvols_0[] = "/dev/sda1";
6335     physvols_0[5] = devchar;
6336     char physvols_1[] = "/dev/sda2";
6337     physvols_1[5] = devchar;
6338     char *physvols[] = {
6339       physvols_0,
6340       physvols_1,
6341       NULL
6342     };
6343     int r;
6344     suppress_error = 0;
6345     r = guestfs_vgcreate (g, volgroup, physvols);
6346     if (r == -1)
6347       return -1;
6348   }
6349   {
6350     char volgroup[] = "VG2";
6351     char physvols_0[] = "/dev/sda3";
6352     physvols_0[5] = devchar;
6353     char *physvols[] = {
6354       physvols_0,
6355       NULL
6356     };
6357     int r;
6358     suppress_error = 0;
6359     r = guestfs_vgcreate (g, volgroup, physvols);
6360     if (r == -1)
6361       return -1;
6362   }
6363   {
6364     char logvol[] = "LV1";
6365     char volgroup[] = "VG1";
6366     int r;
6367     suppress_error = 0;
6368     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6369     if (r == -1)
6370       return -1;
6371   }
6372   {
6373     char logvol[] = "LV2";
6374     char volgroup[] = "VG1";
6375     int r;
6376     suppress_error = 0;
6377     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6378     if (r == -1)
6379       return -1;
6380   }
6381   {
6382     char logvol[] = "LV3";
6383     char volgroup[] = "VG2";
6384     int r;
6385     suppress_error = 0;
6386     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6387     if (r == -1)
6388       return -1;
6389   }
6390   {
6391     char logvol[] = "LV4";
6392     char volgroup[] = "VG2";
6393     int r;
6394     suppress_error = 0;
6395     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6396     if (r == -1)
6397       return -1;
6398   }
6399   {
6400     char logvol[] = "LV5";
6401     char volgroup[] = "VG2";
6402     int r;
6403     suppress_error = 0;
6404     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6405     if (r == -1)
6406       return -1;
6407   }
6408   {
6409     char **r;
6410     int i;
6411     suppress_error = 0;
6412     r = guestfs_lvs (g);
6413     if (r == NULL)
6414       return -1;
6415     if (!r[0]) {
6416       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6417       print_strings (r);
6418       return -1;
6419     }
6420     {
6421       char expected[] = "/dev/VG1/LV1";
6422       if (strcmp (r[0], expected) != 0) {
6423         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6424         return -1;
6425       }
6426     }
6427     if (!r[1]) {
6428       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6429       print_strings (r);
6430       return -1;
6431     }
6432     {
6433       char expected[] = "/dev/VG1/LV2";
6434       if (strcmp (r[1], expected) != 0) {
6435         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6436         return -1;
6437       }
6438     }
6439     if (!r[2]) {
6440       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6441       print_strings (r);
6442       return -1;
6443     }
6444     {
6445       char expected[] = "/dev/VG2/LV3";
6446       if (strcmp (r[2], expected) != 0) {
6447         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6448         return -1;
6449       }
6450     }
6451     if (!r[3]) {
6452       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6453       print_strings (r);
6454       return -1;
6455     }
6456     {
6457       char expected[] = "/dev/VG2/LV4";
6458       if (strcmp (r[3], expected) != 0) {
6459         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
6460         return -1;
6461       }
6462     }
6463     if (!r[4]) {
6464       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6465       print_strings (r);
6466       return -1;
6467     }
6468     {
6469       char expected[] = "/dev/VG2/LV5";
6470       if (strcmp (r[4], expected) != 0) {
6471         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
6472         return -1;
6473       }
6474     }
6475     if (r[5] != NULL) {
6476       fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
6477       print_strings (r);
6478       return -1;
6479     }
6480     for (i = 0; r[i] != NULL; ++i)
6481       free (r[i]);
6482     free (r);
6483   }
6484   return 0;
6485 }
6486
6487 static int test_vgcreate_0 (void)
6488 {
6489   /* InitEmpty for vgcreate (0) */
6490   {
6491     char device[] = "/dev/sda";
6492     device[5] = devchar;
6493     int r;
6494     suppress_error = 0;
6495     r = guestfs_blockdev_setrw (g, device);
6496     if (r == -1)
6497       return -1;
6498   }
6499   {
6500     int r;
6501     suppress_error = 0;
6502     r = guestfs_umount_all (g);
6503     if (r == -1)
6504       return -1;
6505   }
6506   {
6507     int r;
6508     suppress_error = 0;
6509     r = guestfs_lvm_remove_all (g);
6510     if (r == -1)
6511       return -1;
6512   }
6513   /* TestOutputList for vgcreate (0) */
6514   {
6515     char device[] = "/dev/sda";
6516     device[5] = devchar;
6517     char lines_0[] = ",10";
6518     char lines_1[] = ",20";
6519     char lines_2[] = ",";
6520     char *lines[] = {
6521       lines_0,
6522       lines_1,
6523       lines_2,
6524       NULL
6525     };
6526     int r;
6527     suppress_error = 0;
6528     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6529     if (r == -1)
6530       return -1;
6531   }
6532   {
6533     char device[] = "/dev/sda1";
6534     device[5] = devchar;
6535     int r;
6536     suppress_error = 0;
6537     r = guestfs_pvcreate (g, device);
6538     if (r == -1)
6539       return -1;
6540   }
6541   {
6542     char device[] = "/dev/sda2";
6543     device[5] = devchar;
6544     int r;
6545     suppress_error = 0;
6546     r = guestfs_pvcreate (g, device);
6547     if (r == -1)
6548       return -1;
6549   }
6550   {
6551     char device[] = "/dev/sda3";
6552     device[5] = devchar;
6553     int r;
6554     suppress_error = 0;
6555     r = guestfs_pvcreate (g, device);
6556     if (r == -1)
6557       return -1;
6558   }
6559   {
6560     char volgroup[] = "VG1";
6561     char physvols_0[] = "/dev/sda1";
6562     physvols_0[5] = devchar;
6563     char physvols_1[] = "/dev/sda2";
6564     physvols_1[5] = devchar;
6565     char *physvols[] = {
6566       physvols_0,
6567       physvols_1,
6568       NULL
6569     };
6570     int r;
6571     suppress_error = 0;
6572     r = guestfs_vgcreate (g, volgroup, physvols);
6573     if (r == -1)
6574       return -1;
6575   }
6576   {
6577     char volgroup[] = "VG2";
6578     char physvols_0[] = "/dev/sda3";
6579     physvols_0[5] = devchar;
6580     char *physvols[] = {
6581       physvols_0,
6582       NULL
6583     };
6584     int r;
6585     suppress_error = 0;
6586     r = guestfs_vgcreate (g, volgroup, physvols);
6587     if (r == -1)
6588       return -1;
6589   }
6590   {
6591     char **r;
6592     int i;
6593     suppress_error = 0;
6594     r = guestfs_vgs (g);
6595     if (r == NULL)
6596       return -1;
6597     if (!r[0]) {
6598       fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6599       print_strings (r);
6600       return -1;
6601     }
6602     {
6603       char expected[] = "VG1";
6604       if (strcmp (r[0], expected) != 0) {
6605         fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6606         return -1;
6607       }
6608     }
6609     if (!r[1]) {
6610       fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6611       print_strings (r);
6612       return -1;
6613     }
6614     {
6615       char expected[] = "VG2";
6616       if (strcmp (r[1], expected) != 0) {
6617         fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6618         return -1;
6619       }
6620     }
6621     if (r[2] != NULL) {
6622       fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
6623       print_strings (r);
6624       return -1;
6625     }
6626     for (i = 0; r[i] != NULL; ++i)
6627       free (r[i]);
6628     free (r);
6629   }
6630   return 0;
6631 }
6632
6633 static int test_pvcreate_0 (void)
6634 {
6635   /* InitEmpty for pvcreate (0) */
6636   {
6637     char device[] = "/dev/sda";
6638     device[5] = devchar;
6639     int r;
6640     suppress_error = 0;
6641     r = guestfs_blockdev_setrw (g, device);
6642     if (r == -1)
6643       return -1;
6644   }
6645   {
6646     int r;
6647     suppress_error = 0;
6648     r = guestfs_umount_all (g);
6649     if (r == -1)
6650       return -1;
6651   }
6652   {
6653     int r;
6654     suppress_error = 0;
6655     r = guestfs_lvm_remove_all (g);
6656     if (r == -1)
6657       return -1;
6658   }
6659   /* TestOutputList for pvcreate (0) */
6660   {
6661     char device[] = "/dev/sda";
6662     device[5] = devchar;
6663     char lines_0[] = ",10";
6664     char lines_1[] = ",20";
6665     char lines_2[] = ",";
6666     char *lines[] = {
6667       lines_0,
6668       lines_1,
6669       lines_2,
6670       NULL
6671     };
6672     int r;
6673     suppress_error = 0;
6674     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6675     if (r == -1)
6676       return -1;
6677   }
6678   {
6679     char device[] = "/dev/sda1";
6680     device[5] = devchar;
6681     int r;
6682     suppress_error = 0;
6683     r = guestfs_pvcreate (g, device);
6684     if (r == -1)
6685       return -1;
6686   }
6687   {
6688     char device[] = "/dev/sda2";
6689     device[5] = devchar;
6690     int r;
6691     suppress_error = 0;
6692     r = guestfs_pvcreate (g, device);
6693     if (r == -1)
6694       return -1;
6695   }
6696   {
6697     char device[] = "/dev/sda3";
6698     device[5] = devchar;
6699     int r;
6700     suppress_error = 0;
6701     r = guestfs_pvcreate (g, device);
6702     if (r == -1)
6703       return -1;
6704   }
6705   {
6706     char **r;
6707     int i;
6708     suppress_error = 0;
6709     r = guestfs_pvs (g);
6710     if (r == NULL)
6711       return -1;
6712     if (!r[0]) {
6713       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6714       print_strings (r);
6715       return -1;
6716     }
6717     {
6718       char expected[] = "/dev/sda1";
6719       expected[5] = devchar;
6720       if (strcmp (r[0], expected) != 0) {
6721         fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6722         return -1;
6723       }
6724     }
6725     if (!r[1]) {
6726       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6727       print_strings (r);
6728       return -1;
6729     }
6730     {
6731       char expected[] = "/dev/sda2";
6732       expected[5] = devchar;
6733       if (strcmp (r[1], expected) != 0) {
6734         fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6735         return -1;
6736       }
6737     }
6738     if (!r[2]) {
6739       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6740       print_strings (r);
6741       return -1;
6742     }
6743     {
6744       char expected[] = "/dev/sda3";
6745       expected[5] = devchar;
6746       if (strcmp (r[2], expected) != 0) {
6747         fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6748         return -1;
6749       }
6750     }
6751     if (r[3] != NULL) {
6752       fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
6753       print_strings (r);
6754       return -1;
6755     }
6756     for (i = 0; r[i] != NULL; ++i)
6757       free (r[i]);
6758     free (r);
6759   }
6760   return 0;
6761 }
6762
6763 static int test_is_dir_0 (void)
6764 {
6765   /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
6766   {
6767     char device[] = "/dev/sda";
6768     device[5] = devchar;
6769     int r;
6770     suppress_error = 0;
6771     r = guestfs_blockdev_setrw (g, device);
6772     if (r == -1)
6773       return -1;
6774   }
6775   {
6776     int r;
6777     suppress_error = 0;
6778     r = guestfs_umount_all (g);
6779     if (r == -1)
6780       return -1;
6781   }
6782   {
6783     int r;
6784     suppress_error = 0;
6785     r = guestfs_lvm_remove_all (g);
6786     if (r == -1)
6787       return -1;
6788   }
6789   {
6790     char device[] = "/dev/sda";
6791     device[5] = devchar;
6792     char lines_0[] = ",";
6793     char *lines[] = {
6794       lines_0,
6795       NULL
6796     };
6797     int r;
6798     suppress_error = 0;
6799     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6800     if (r == -1)
6801       return -1;
6802   }
6803   {
6804     char fstype[] = "ext2";
6805     char device[] = "/dev/sda1";
6806     device[5] = devchar;
6807     int r;
6808     suppress_error = 0;
6809     r = guestfs_mkfs (g, fstype, device);
6810     if (r == -1)
6811       return -1;
6812   }
6813   {
6814     char device[] = "/dev/sda1";
6815     device[5] = devchar;
6816     char mountpoint[] = "/";
6817     int r;
6818     suppress_error = 0;
6819     r = guestfs_mount (g, device, mountpoint);
6820     if (r == -1)
6821       return -1;
6822   }
6823   /* TestOutputFalse for is_dir (0) */
6824   {
6825     char path[] = "/new";
6826     int r;
6827     suppress_error = 0;
6828     r = guestfs_touch (g, path);
6829     if (r == -1)
6830       return -1;
6831   }
6832   {
6833     char path[] = "/new";
6834     int r;
6835     suppress_error = 0;
6836     r = guestfs_is_dir (g, path);
6837     if (r == -1)
6838       return -1;
6839     if (r) {
6840       fprintf (stderr, "test_is_dir_0: expected false, got true\n");
6841       return -1;
6842     }
6843   }
6844   return 0;
6845 }
6846
6847 static int test_is_dir_1 (void)
6848 {
6849   /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
6850   {
6851     char device[] = "/dev/sda";
6852     device[5] = devchar;
6853     int r;
6854     suppress_error = 0;
6855     r = guestfs_blockdev_setrw (g, device);
6856     if (r == -1)
6857       return -1;
6858   }
6859   {
6860     int r;
6861     suppress_error = 0;
6862     r = guestfs_umount_all (g);
6863     if (r == -1)
6864       return -1;
6865   }
6866   {
6867     int r;
6868     suppress_error = 0;
6869     r = guestfs_lvm_remove_all (g);
6870     if (r == -1)
6871       return -1;
6872   }
6873   {
6874     char device[] = "/dev/sda";
6875     device[5] = devchar;
6876     char lines_0[] = ",";
6877     char *lines[] = {
6878       lines_0,
6879       NULL
6880     };
6881     int r;
6882     suppress_error = 0;
6883     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6884     if (r == -1)
6885       return -1;
6886   }
6887   {
6888     char fstype[] = "ext2";
6889     char device[] = "/dev/sda1";
6890     device[5] = devchar;
6891     int r;
6892     suppress_error = 0;
6893     r = guestfs_mkfs (g, fstype, device);
6894     if (r == -1)
6895       return -1;
6896   }
6897   {
6898     char device[] = "/dev/sda1";
6899     device[5] = devchar;
6900     char mountpoint[] = "/";
6901     int r;
6902     suppress_error = 0;
6903     r = guestfs_mount (g, device, mountpoint);
6904     if (r == -1)
6905       return -1;
6906   }
6907   /* TestOutputTrue for is_dir (1) */
6908   {
6909     char path[] = "/new";
6910     int r;
6911     suppress_error = 0;
6912     r = guestfs_mkdir (g, path);
6913     if (r == -1)
6914       return -1;
6915   }
6916   {
6917     char path[] = "/new";
6918     int r;
6919     suppress_error = 0;
6920     r = guestfs_is_dir (g, path);
6921     if (r == -1)
6922       return -1;
6923     if (!r) {
6924       fprintf (stderr, "test_is_dir_1: expected true, got false\n");
6925       return -1;
6926     }
6927   }
6928   return 0;
6929 }
6930
6931 static int test_is_file_0 (void)
6932 {
6933   /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
6934   {
6935     char device[] = "/dev/sda";
6936     device[5] = devchar;
6937     int r;
6938     suppress_error = 0;
6939     r = guestfs_blockdev_setrw (g, device);
6940     if (r == -1)
6941       return -1;
6942   }
6943   {
6944     int r;
6945     suppress_error = 0;
6946     r = guestfs_umount_all (g);
6947     if (r == -1)
6948       return -1;
6949   }
6950   {
6951     int r;
6952     suppress_error = 0;
6953     r = guestfs_lvm_remove_all (g);
6954     if (r == -1)
6955       return -1;
6956   }
6957   {
6958     char device[] = "/dev/sda";
6959     device[5] = devchar;
6960     char lines_0[] = ",";
6961     char *lines[] = {
6962       lines_0,
6963       NULL
6964     };
6965     int r;
6966     suppress_error = 0;
6967     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6968     if (r == -1)
6969       return -1;
6970   }
6971   {
6972     char fstype[] = "ext2";
6973     char device[] = "/dev/sda1";
6974     device[5] = devchar;
6975     int r;
6976     suppress_error = 0;
6977     r = guestfs_mkfs (g, fstype, device);
6978     if (r == -1)
6979       return -1;
6980   }
6981   {
6982     char device[] = "/dev/sda1";
6983     device[5] = devchar;
6984     char mountpoint[] = "/";
6985     int r;
6986     suppress_error = 0;
6987     r = guestfs_mount (g, device, mountpoint);
6988     if (r == -1)
6989       return -1;
6990   }
6991   /* TestOutputTrue for is_file (0) */
6992   {
6993     char path[] = "/new";
6994     int r;
6995     suppress_error = 0;
6996     r = guestfs_touch (g, path);
6997     if (r == -1)
6998       return -1;
6999   }
7000   {
7001     char path[] = "/new";
7002     int r;
7003     suppress_error = 0;
7004     r = guestfs_is_file (g, path);
7005     if (r == -1)
7006       return -1;
7007     if (!r) {
7008       fprintf (stderr, "test_is_file_0: expected true, got false\n");
7009       return -1;
7010     }
7011   }
7012   return 0;
7013 }
7014
7015 static int test_is_file_1 (void)
7016 {
7017   /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
7018   {
7019     char device[] = "/dev/sda";
7020     device[5] = devchar;
7021     int r;
7022     suppress_error = 0;
7023     r = guestfs_blockdev_setrw (g, device);
7024     if (r == -1)
7025       return -1;
7026   }
7027   {
7028     int r;
7029     suppress_error = 0;
7030     r = guestfs_umount_all (g);
7031     if (r == -1)
7032       return -1;
7033   }
7034   {
7035     int r;
7036     suppress_error = 0;
7037     r = guestfs_lvm_remove_all (g);
7038     if (r == -1)
7039       return -1;
7040   }
7041   {
7042     char device[] = "/dev/sda";
7043     device[5] = devchar;
7044     char lines_0[] = ",";
7045     char *lines[] = {
7046       lines_0,
7047       NULL
7048     };
7049     int r;
7050     suppress_error = 0;
7051     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7052     if (r == -1)
7053       return -1;
7054   }
7055   {
7056     char fstype[] = "ext2";
7057     char device[] = "/dev/sda1";
7058     device[5] = devchar;
7059     int r;
7060     suppress_error = 0;
7061     r = guestfs_mkfs (g, fstype, device);
7062     if (r == -1)
7063       return -1;
7064   }
7065   {
7066     char device[] = "/dev/sda1";
7067     device[5] = devchar;
7068     char mountpoint[] = "/";
7069     int r;
7070     suppress_error = 0;
7071     r = guestfs_mount (g, device, mountpoint);
7072     if (r == -1)
7073       return -1;
7074   }
7075   /* TestOutputFalse for is_file (1) */
7076   {
7077     char path[] = "/new";
7078     int r;
7079     suppress_error = 0;
7080     r = guestfs_mkdir (g, path);
7081     if (r == -1)
7082       return -1;
7083   }
7084   {
7085     char path[] = "/new";
7086     int r;
7087     suppress_error = 0;
7088     r = guestfs_is_file (g, path);
7089     if (r == -1)
7090       return -1;
7091     if (r) {
7092       fprintf (stderr, "test_is_file_1: expected false, got true\n");
7093       return -1;
7094     }
7095   }
7096   return 0;
7097 }
7098
7099 static int test_exists_0 (void)
7100 {
7101   /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
7102   {
7103     char device[] = "/dev/sda";
7104     device[5] = devchar;
7105     int r;
7106     suppress_error = 0;
7107     r = guestfs_blockdev_setrw (g, device);
7108     if (r == -1)
7109       return -1;
7110   }
7111   {
7112     int r;
7113     suppress_error = 0;
7114     r = guestfs_umount_all (g);
7115     if (r == -1)
7116       return -1;
7117   }
7118   {
7119     int r;
7120     suppress_error = 0;
7121     r = guestfs_lvm_remove_all (g);
7122     if (r == -1)
7123       return -1;
7124   }
7125   {
7126     char device[] = "/dev/sda";
7127     device[5] = devchar;
7128     char lines_0[] = ",";
7129     char *lines[] = {
7130       lines_0,
7131       NULL
7132     };
7133     int r;
7134     suppress_error = 0;
7135     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7136     if (r == -1)
7137       return -1;
7138   }
7139   {
7140     char fstype[] = "ext2";
7141     char device[] = "/dev/sda1";
7142     device[5] = devchar;
7143     int r;
7144     suppress_error = 0;
7145     r = guestfs_mkfs (g, fstype, device);
7146     if (r == -1)
7147       return -1;
7148   }
7149   {
7150     char device[] = "/dev/sda1";
7151     device[5] = devchar;
7152     char mountpoint[] = "/";
7153     int r;
7154     suppress_error = 0;
7155     r = guestfs_mount (g, device, mountpoint);
7156     if (r == -1)
7157       return -1;
7158   }
7159   /* TestOutputTrue for exists (0) */
7160   {
7161     char path[] = "/new";
7162     int r;
7163     suppress_error = 0;
7164     r = guestfs_touch (g, path);
7165     if (r == -1)
7166       return -1;
7167   }
7168   {
7169     char path[] = "/new";
7170     int r;
7171     suppress_error = 0;
7172     r = guestfs_exists (g, path);
7173     if (r == -1)
7174       return -1;
7175     if (!r) {
7176       fprintf (stderr, "test_exists_0: expected true, got false\n");
7177       return -1;
7178     }
7179   }
7180   return 0;
7181 }
7182
7183 static int test_exists_1 (void)
7184 {
7185   /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
7186   {
7187     char device[] = "/dev/sda";
7188     device[5] = devchar;
7189     int r;
7190     suppress_error = 0;
7191     r = guestfs_blockdev_setrw (g, device);
7192     if (r == -1)
7193       return -1;
7194   }
7195   {
7196     int r;
7197     suppress_error = 0;
7198     r = guestfs_umount_all (g);
7199     if (r == -1)
7200       return -1;
7201   }
7202   {
7203     int r;
7204     suppress_error = 0;
7205     r = guestfs_lvm_remove_all (g);
7206     if (r == -1)
7207       return -1;
7208   }
7209   {
7210     char device[] = "/dev/sda";
7211     device[5] = devchar;
7212     char lines_0[] = ",";
7213     char *lines[] = {
7214       lines_0,
7215       NULL
7216     };
7217     int r;
7218     suppress_error = 0;
7219     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7220     if (r == -1)
7221       return -1;
7222   }
7223   {
7224     char fstype[] = "ext2";
7225     char device[] = "/dev/sda1";
7226     device[5] = devchar;
7227     int r;
7228     suppress_error = 0;
7229     r = guestfs_mkfs (g, fstype, device);
7230     if (r == -1)
7231       return -1;
7232   }
7233   {
7234     char device[] = "/dev/sda1";
7235     device[5] = devchar;
7236     char mountpoint[] = "/";
7237     int r;
7238     suppress_error = 0;
7239     r = guestfs_mount (g, device, mountpoint);
7240     if (r == -1)
7241       return -1;
7242   }
7243   /* TestOutputTrue for exists (1) */
7244   {
7245     char path[] = "/new";
7246     int r;
7247     suppress_error = 0;
7248     r = guestfs_mkdir (g, path);
7249     if (r == -1)
7250       return -1;
7251   }
7252   {
7253     char path[] = "/new";
7254     int r;
7255     suppress_error = 0;
7256     r = guestfs_exists (g, path);
7257     if (r == -1)
7258       return -1;
7259     if (!r) {
7260       fprintf (stderr, "test_exists_1: expected true, got false\n");
7261       return -1;
7262     }
7263   }
7264   return 0;
7265 }
7266
7267 static int test_mkdir_p_0 (void)
7268 {
7269   /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
7270   {
7271     char device[] = "/dev/sda";
7272     device[5] = devchar;
7273     int r;
7274     suppress_error = 0;
7275     r = guestfs_blockdev_setrw (g, device);
7276     if (r == -1)
7277       return -1;
7278   }
7279   {
7280     int r;
7281     suppress_error = 0;
7282     r = guestfs_umount_all (g);
7283     if (r == -1)
7284       return -1;
7285   }
7286   {
7287     int r;
7288     suppress_error = 0;
7289     r = guestfs_lvm_remove_all (g);
7290     if (r == -1)
7291       return -1;
7292   }
7293   {
7294     char device[] = "/dev/sda";
7295     device[5] = devchar;
7296     char lines_0[] = ",";
7297     char *lines[] = {
7298       lines_0,
7299       NULL
7300     };
7301     int r;
7302     suppress_error = 0;
7303     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7304     if (r == -1)
7305       return -1;
7306   }
7307   {
7308     char fstype[] = "ext2";
7309     char device[] = "/dev/sda1";
7310     device[5] = devchar;
7311     int r;
7312     suppress_error = 0;
7313     r = guestfs_mkfs (g, fstype, device);
7314     if (r == -1)
7315       return -1;
7316   }
7317   {
7318     char device[] = "/dev/sda1";
7319     device[5] = devchar;
7320     char mountpoint[] = "/";
7321     int r;
7322     suppress_error = 0;
7323     r = guestfs_mount (g, device, mountpoint);
7324     if (r == -1)
7325       return -1;
7326   }
7327   /* TestOutputTrue for mkdir_p (0) */
7328   {
7329     char path[] = "/new/foo/bar";
7330     int r;
7331     suppress_error = 0;
7332     r = guestfs_mkdir_p (g, path);
7333     if (r == -1)
7334       return -1;
7335   }
7336   {
7337     char path[] = "/new/foo/bar";
7338     int r;
7339     suppress_error = 0;
7340     r = guestfs_is_dir (g, path);
7341     if (r == -1)
7342       return -1;
7343     if (!r) {
7344       fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
7345       return -1;
7346     }
7347   }
7348   return 0;
7349 }
7350
7351 static int test_mkdir_p_1 (void)
7352 {
7353   /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
7354   {
7355     char device[] = "/dev/sda";
7356     device[5] = devchar;
7357     int r;
7358     suppress_error = 0;
7359     r = guestfs_blockdev_setrw (g, device);
7360     if (r == -1)
7361       return -1;
7362   }
7363   {
7364     int r;
7365     suppress_error = 0;
7366     r = guestfs_umount_all (g);
7367     if (r == -1)
7368       return -1;
7369   }
7370   {
7371     int r;
7372     suppress_error = 0;
7373     r = guestfs_lvm_remove_all (g);
7374     if (r == -1)
7375       return -1;
7376   }
7377   {
7378     char device[] = "/dev/sda";
7379     device[5] = devchar;
7380     char lines_0[] = ",";
7381     char *lines[] = {
7382       lines_0,
7383       NULL
7384     };
7385     int r;
7386     suppress_error = 0;
7387     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7388     if (r == -1)
7389       return -1;
7390   }
7391   {
7392     char fstype[] = "ext2";
7393     char device[] = "/dev/sda1";
7394     device[5] = devchar;
7395     int r;
7396     suppress_error = 0;
7397     r = guestfs_mkfs (g, fstype, device);
7398     if (r == -1)
7399       return -1;
7400   }
7401   {
7402     char device[] = "/dev/sda1";
7403     device[5] = devchar;
7404     char mountpoint[] = "/";
7405     int r;
7406     suppress_error = 0;
7407     r = guestfs_mount (g, device, mountpoint);
7408     if (r == -1)
7409       return -1;
7410   }
7411   /* TestOutputTrue for mkdir_p (1) */
7412   {
7413     char path[] = "/new/foo/bar";
7414     int r;
7415     suppress_error = 0;
7416     r = guestfs_mkdir_p (g, path);
7417     if (r == -1)
7418       return -1;
7419   }
7420   {
7421     char path[] = "/new/foo";
7422     int r;
7423     suppress_error = 0;
7424     r = guestfs_is_dir (g, path);
7425     if (r == -1)
7426       return -1;
7427     if (!r) {
7428       fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
7429       return -1;
7430     }
7431   }
7432   return 0;
7433 }
7434
7435 static int test_mkdir_p_2 (void)
7436 {
7437   /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
7438   {
7439     char device[] = "/dev/sda";
7440     device[5] = devchar;
7441     int r;
7442     suppress_error = 0;
7443     r = guestfs_blockdev_setrw (g, device);
7444     if (r == -1)
7445       return -1;
7446   }
7447   {
7448     int r;
7449     suppress_error = 0;
7450     r = guestfs_umount_all (g);
7451     if (r == -1)
7452       return -1;
7453   }
7454   {
7455     int r;
7456     suppress_error = 0;
7457     r = guestfs_lvm_remove_all (g);
7458     if (r == -1)
7459       return -1;
7460   }
7461   {
7462     char device[] = "/dev/sda";
7463     device[5] = devchar;
7464     char lines_0[] = ",";
7465     char *lines[] = {
7466       lines_0,
7467       NULL
7468     };
7469     int r;
7470     suppress_error = 0;
7471     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7472     if (r == -1)
7473       return -1;
7474   }
7475   {
7476     char fstype[] = "ext2";
7477     char device[] = "/dev/sda1";
7478     device[5] = devchar;
7479     int r;
7480     suppress_error = 0;
7481     r = guestfs_mkfs (g, fstype, device);
7482     if (r == -1)
7483       return -1;
7484   }
7485   {
7486     char device[] = "/dev/sda1";
7487     device[5] = devchar;
7488     char mountpoint[] = "/";
7489     int r;
7490     suppress_error = 0;
7491     r = guestfs_mount (g, device, mountpoint);
7492     if (r == -1)
7493       return -1;
7494   }
7495   /* TestOutputTrue for mkdir_p (2) */
7496   {
7497     char path[] = "/new/foo/bar";
7498     int r;
7499     suppress_error = 0;
7500     r = guestfs_mkdir_p (g, path);
7501     if (r == -1)
7502       return -1;
7503   }
7504   {
7505     char path[] = "/new";
7506     int r;
7507     suppress_error = 0;
7508     r = guestfs_is_dir (g, path);
7509     if (r == -1)
7510       return -1;
7511     if (!r) {
7512       fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
7513       return -1;
7514     }
7515   }
7516   return 0;
7517 }
7518
7519 static int test_mkdir_0 (void)
7520 {
7521   /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
7522   {
7523     char device[] = "/dev/sda";
7524     device[5] = devchar;
7525     int r;
7526     suppress_error = 0;
7527     r = guestfs_blockdev_setrw (g, device);
7528     if (r == -1)
7529       return -1;
7530   }
7531   {
7532     int r;
7533     suppress_error = 0;
7534     r = guestfs_umount_all (g);
7535     if (r == -1)
7536       return -1;
7537   }
7538   {
7539     int r;
7540     suppress_error = 0;
7541     r = guestfs_lvm_remove_all (g);
7542     if (r == -1)
7543       return -1;
7544   }
7545   {
7546     char device[] = "/dev/sda";
7547     device[5] = devchar;
7548     char lines_0[] = ",";
7549     char *lines[] = {
7550       lines_0,
7551       NULL
7552     };
7553     int r;
7554     suppress_error = 0;
7555     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7556     if (r == -1)
7557       return -1;
7558   }
7559   {
7560     char fstype[] = "ext2";
7561     char device[] = "/dev/sda1";
7562     device[5] = devchar;
7563     int r;
7564     suppress_error = 0;
7565     r = guestfs_mkfs (g, fstype, device);
7566     if (r == -1)
7567       return -1;
7568   }
7569   {
7570     char device[] = "/dev/sda1";
7571     device[5] = devchar;
7572     char mountpoint[] = "/";
7573     int r;
7574     suppress_error = 0;
7575     r = guestfs_mount (g, device, mountpoint);
7576     if (r == -1)
7577       return -1;
7578   }
7579   /* TestOutputTrue for mkdir (0) */
7580   {
7581     char path[] = "/new";
7582     int r;
7583     suppress_error = 0;
7584     r = guestfs_mkdir (g, path);
7585     if (r == -1)
7586       return -1;
7587   }
7588   {
7589     char path[] = "/new";
7590     int r;
7591     suppress_error = 0;
7592     r = guestfs_is_dir (g, path);
7593     if (r == -1)
7594       return -1;
7595     if (!r) {
7596       fprintf (stderr, "test_mkdir_0: expected true, got false\n");
7597       return -1;
7598     }
7599   }
7600   return 0;
7601 }
7602
7603 static int test_mkdir_1 (void)
7604 {
7605   /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
7606   {
7607     char device[] = "/dev/sda";
7608     device[5] = devchar;
7609     int r;
7610     suppress_error = 0;
7611     r = guestfs_blockdev_setrw (g, device);
7612     if (r == -1)
7613       return -1;
7614   }
7615   {
7616     int r;
7617     suppress_error = 0;
7618     r = guestfs_umount_all (g);
7619     if (r == -1)
7620       return -1;
7621   }
7622   {
7623     int r;
7624     suppress_error = 0;
7625     r = guestfs_lvm_remove_all (g);
7626     if (r == -1)
7627       return -1;
7628   }
7629   {
7630     char device[] = "/dev/sda";
7631     device[5] = devchar;
7632     char lines_0[] = ",";
7633     char *lines[] = {
7634       lines_0,
7635       NULL
7636     };
7637     int r;
7638     suppress_error = 0;
7639     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7640     if (r == -1)
7641       return -1;
7642   }
7643   {
7644     char fstype[] = "ext2";
7645     char device[] = "/dev/sda1";
7646     device[5] = devchar;
7647     int r;
7648     suppress_error = 0;
7649     r = guestfs_mkfs (g, fstype, device);
7650     if (r == -1)
7651       return -1;
7652   }
7653   {
7654     char device[] = "/dev/sda1";
7655     device[5] = devchar;
7656     char mountpoint[] = "/";
7657     int r;
7658     suppress_error = 0;
7659     r = guestfs_mount (g, device, mountpoint);
7660     if (r == -1)
7661       return -1;
7662   }
7663   /* TestLastFail for mkdir (1) */
7664   {
7665     char path[] = "/new/foo/bar";
7666     int r;
7667     suppress_error = 1;
7668     r = guestfs_mkdir (g, path);
7669     if (r != -1)
7670       return -1;
7671   }
7672   return 0;
7673 }
7674
7675 static int test_rm_rf_0 (void)
7676 {
7677   /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
7678   {
7679     char device[] = "/dev/sda";
7680     device[5] = devchar;
7681     int r;
7682     suppress_error = 0;
7683     r = guestfs_blockdev_setrw (g, device);
7684     if (r == -1)
7685       return -1;
7686   }
7687   {
7688     int r;
7689     suppress_error = 0;
7690     r = guestfs_umount_all (g);
7691     if (r == -1)
7692       return -1;
7693   }
7694   {
7695     int r;
7696     suppress_error = 0;
7697     r = guestfs_lvm_remove_all (g);
7698     if (r == -1)
7699       return -1;
7700   }
7701   {
7702     char device[] = "/dev/sda";
7703     device[5] = devchar;
7704     char lines_0[] = ",";
7705     char *lines[] = {
7706       lines_0,
7707       NULL
7708     };
7709     int r;
7710     suppress_error = 0;
7711     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7712     if (r == -1)
7713       return -1;
7714   }
7715   {
7716     char fstype[] = "ext2";
7717     char device[] = "/dev/sda1";
7718     device[5] = devchar;
7719     int r;
7720     suppress_error = 0;
7721     r = guestfs_mkfs (g, fstype, device);
7722     if (r == -1)
7723       return -1;
7724   }
7725   {
7726     char device[] = "/dev/sda1";
7727     device[5] = devchar;
7728     char mountpoint[] = "/";
7729     int r;
7730     suppress_error = 0;
7731     r = guestfs_mount (g, device, mountpoint);
7732     if (r == -1)
7733       return -1;
7734   }
7735   /* TestOutputFalse for rm_rf (0) */
7736   {
7737     char path[] = "/new";
7738     int r;
7739     suppress_error = 0;
7740     r = guestfs_mkdir (g, path);
7741     if (r == -1)
7742       return -1;
7743   }
7744   {
7745     char path[] = "/new/foo";
7746     int r;
7747     suppress_error = 0;
7748     r = guestfs_mkdir (g, path);
7749     if (r == -1)
7750       return -1;
7751   }
7752   {
7753     char path[] = "/new/foo/bar";
7754     int r;
7755     suppress_error = 0;
7756     r = guestfs_touch (g, path);
7757     if (r == -1)
7758       return -1;
7759   }
7760   {
7761     char path[] = "/new";
7762     int r;
7763     suppress_error = 0;
7764     r = guestfs_rm_rf (g, path);
7765     if (r == -1)
7766       return -1;
7767   }
7768   {
7769     char path[] = "/new";
7770     int r;
7771     suppress_error = 0;
7772     r = guestfs_exists (g, path);
7773     if (r == -1)
7774       return -1;
7775     if (r) {
7776       fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
7777       return -1;
7778     }
7779   }
7780   return 0;
7781 }
7782
7783 static int test_rmdir_0 (void)
7784 {
7785   /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
7786   {
7787     char device[] = "/dev/sda";
7788     device[5] = devchar;
7789     int r;
7790     suppress_error = 0;
7791     r = guestfs_blockdev_setrw (g, device);
7792     if (r == -1)
7793       return -1;
7794   }
7795   {
7796     int r;
7797     suppress_error = 0;
7798     r = guestfs_umount_all (g);
7799     if (r == -1)
7800       return -1;
7801   }
7802   {
7803     int r;
7804     suppress_error = 0;
7805     r = guestfs_lvm_remove_all (g);
7806     if (r == -1)
7807       return -1;
7808   }
7809   {
7810     char device[] = "/dev/sda";
7811     device[5] = devchar;
7812     char lines_0[] = ",";
7813     char *lines[] = {
7814       lines_0,
7815       NULL
7816     };
7817     int r;
7818     suppress_error = 0;
7819     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7820     if (r == -1)
7821       return -1;
7822   }
7823   {
7824     char fstype[] = "ext2";
7825     char device[] = "/dev/sda1";
7826     device[5] = devchar;
7827     int r;
7828     suppress_error = 0;
7829     r = guestfs_mkfs (g, fstype, device);
7830     if (r == -1)
7831       return -1;
7832   }
7833   {
7834     char device[] = "/dev/sda1";
7835     device[5] = devchar;
7836     char mountpoint[] = "/";
7837     int r;
7838     suppress_error = 0;
7839     r = guestfs_mount (g, device, mountpoint);
7840     if (r == -1)
7841       return -1;
7842   }
7843   /* TestRun for rmdir (0) */
7844   {
7845     char path[] = "/new";
7846     int r;
7847     suppress_error = 0;
7848     r = guestfs_mkdir (g, path);
7849     if (r == -1)
7850       return -1;
7851   }
7852   {
7853     char path[] = "/new";
7854     int r;
7855     suppress_error = 0;
7856     r = guestfs_rmdir (g, path);
7857     if (r == -1)
7858       return -1;
7859   }
7860   return 0;
7861 }
7862
7863 static int test_rmdir_1 (void)
7864 {
7865   /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
7866   {
7867     char device[] = "/dev/sda";
7868     device[5] = devchar;
7869     int r;
7870     suppress_error = 0;
7871     r = guestfs_blockdev_setrw (g, device);
7872     if (r == -1)
7873       return -1;
7874   }
7875   {
7876     int r;
7877     suppress_error = 0;
7878     r = guestfs_umount_all (g);
7879     if (r == -1)
7880       return -1;
7881   }
7882   {
7883     int r;
7884     suppress_error = 0;
7885     r = guestfs_lvm_remove_all (g);
7886     if (r == -1)
7887       return -1;
7888   }
7889   {
7890     char device[] = "/dev/sda";
7891     device[5] = devchar;
7892     char lines_0[] = ",";
7893     char *lines[] = {
7894       lines_0,
7895       NULL
7896     };
7897     int r;
7898     suppress_error = 0;
7899     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7900     if (r == -1)
7901       return -1;
7902   }
7903   {
7904     char fstype[] = "ext2";
7905     char device[] = "/dev/sda1";
7906     device[5] = devchar;
7907     int r;
7908     suppress_error = 0;
7909     r = guestfs_mkfs (g, fstype, device);
7910     if (r == -1)
7911       return -1;
7912   }
7913   {
7914     char device[] = "/dev/sda1";
7915     device[5] = devchar;
7916     char mountpoint[] = "/";
7917     int r;
7918     suppress_error = 0;
7919     r = guestfs_mount (g, device, mountpoint);
7920     if (r == -1)
7921       return -1;
7922   }
7923   /* TestLastFail for rmdir (1) */
7924   {
7925     char path[] = "/new";
7926     int r;
7927     suppress_error = 1;
7928     r = guestfs_rmdir (g, path);
7929     if (r != -1)
7930       return -1;
7931   }
7932   return 0;
7933 }
7934
7935 static int test_rmdir_2 (void)
7936 {
7937   /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
7938   {
7939     char device[] = "/dev/sda";
7940     device[5] = devchar;
7941     int r;
7942     suppress_error = 0;
7943     r = guestfs_blockdev_setrw (g, device);
7944     if (r == -1)
7945       return -1;
7946   }
7947   {
7948     int r;
7949     suppress_error = 0;
7950     r = guestfs_umount_all (g);
7951     if (r == -1)
7952       return -1;
7953   }
7954   {
7955     int r;
7956     suppress_error = 0;
7957     r = guestfs_lvm_remove_all (g);
7958     if (r == -1)
7959       return -1;
7960   }
7961   {
7962     char device[] = "/dev/sda";
7963     device[5] = devchar;
7964     char lines_0[] = ",";
7965     char *lines[] = {
7966       lines_0,
7967       NULL
7968     };
7969     int r;
7970     suppress_error = 0;
7971     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7972     if (r == -1)
7973       return -1;
7974   }
7975   {
7976     char fstype[] = "ext2";
7977     char device[] = "/dev/sda1";
7978     device[5] = devchar;
7979     int r;
7980     suppress_error = 0;
7981     r = guestfs_mkfs (g, fstype, device);
7982     if (r == -1)
7983       return -1;
7984   }
7985   {
7986     char device[] = "/dev/sda1";
7987     device[5] = devchar;
7988     char mountpoint[] = "/";
7989     int r;
7990     suppress_error = 0;
7991     r = guestfs_mount (g, device, mountpoint);
7992     if (r == -1)
7993       return -1;
7994   }
7995   /* TestLastFail for rmdir (2) */
7996   {
7997     char path[] = "/new";
7998     int r;
7999     suppress_error = 0;
8000     r = guestfs_touch (g, path);
8001     if (r == -1)
8002       return -1;
8003   }
8004   {
8005     char path[] = "/new";
8006     int r;
8007     suppress_error = 1;
8008     r = guestfs_rmdir (g, path);
8009     if (r != -1)
8010       return -1;
8011   }
8012   return 0;
8013 }
8014
8015 static int test_rm_0 (void)
8016 {
8017   /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
8018   {
8019     char device[] = "/dev/sda";
8020     device[5] = devchar;
8021     int r;
8022     suppress_error = 0;
8023     r = guestfs_blockdev_setrw (g, device);
8024     if (r == -1)
8025       return -1;
8026   }
8027   {
8028     int r;
8029     suppress_error = 0;
8030     r = guestfs_umount_all (g);
8031     if (r == -1)
8032       return -1;
8033   }
8034   {
8035     int r;
8036     suppress_error = 0;
8037     r = guestfs_lvm_remove_all (g);
8038     if (r == -1)
8039       return -1;
8040   }
8041   {
8042     char device[] = "/dev/sda";
8043     device[5] = devchar;
8044     char lines_0[] = ",";
8045     char *lines[] = {
8046       lines_0,
8047       NULL
8048     };
8049     int r;
8050     suppress_error = 0;
8051     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8052     if (r == -1)
8053       return -1;
8054   }
8055   {
8056     char fstype[] = "ext2";
8057     char device[] = "/dev/sda1";
8058     device[5] = devchar;
8059     int r;
8060     suppress_error = 0;
8061     r = guestfs_mkfs (g, fstype, device);
8062     if (r == -1)
8063       return -1;
8064   }
8065   {
8066     char device[] = "/dev/sda1";
8067     device[5] = devchar;
8068     char mountpoint[] = "/";
8069     int r;
8070     suppress_error = 0;
8071     r = guestfs_mount (g, device, mountpoint);
8072     if (r == -1)
8073       return -1;
8074   }
8075   /* TestRun for rm (0) */
8076   {
8077     char path[] = "/new";
8078     int r;
8079     suppress_error = 0;
8080     r = guestfs_touch (g, path);
8081     if (r == -1)
8082       return -1;
8083   }
8084   {
8085     char path[] = "/new";
8086     int r;
8087     suppress_error = 0;
8088     r = guestfs_rm (g, path);
8089     if (r == -1)
8090       return -1;
8091   }
8092   return 0;
8093 }
8094
8095 static int test_rm_1 (void)
8096 {
8097   /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
8098   {
8099     char device[] = "/dev/sda";
8100     device[5] = devchar;
8101     int r;
8102     suppress_error = 0;
8103     r = guestfs_blockdev_setrw (g, device);
8104     if (r == -1)
8105       return -1;
8106   }
8107   {
8108     int r;
8109     suppress_error = 0;
8110     r = guestfs_umount_all (g);
8111     if (r == -1)
8112       return -1;
8113   }
8114   {
8115     int r;
8116     suppress_error = 0;
8117     r = guestfs_lvm_remove_all (g);
8118     if (r == -1)
8119       return -1;
8120   }
8121   {
8122     char device[] = "/dev/sda";
8123     device[5] = devchar;
8124     char lines_0[] = ",";
8125     char *lines[] = {
8126       lines_0,
8127       NULL
8128     };
8129     int r;
8130     suppress_error = 0;
8131     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8132     if (r == -1)
8133       return -1;
8134   }
8135   {
8136     char fstype[] = "ext2";
8137     char device[] = "/dev/sda1";
8138     device[5] = devchar;
8139     int r;
8140     suppress_error = 0;
8141     r = guestfs_mkfs (g, fstype, device);
8142     if (r == -1)
8143       return -1;
8144   }
8145   {
8146     char device[] = "/dev/sda1";
8147     device[5] = devchar;
8148     char mountpoint[] = "/";
8149     int r;
8150     suppress_error = 0;
8151     r = guestfs_mount (g, device, mountpoint);
8152     if (r == -1)
8153       return -1;
8154   }
8155   /* TestLastFail for rm (1) */
8156   {
8157     char path[] = "/new";
8158     int r;
8159     suppress_error = 1;
8160     r = guestfs_rm (g, path);
8161     if (r != -1)
8162       return -1;
8163   }
8164   return 0;
8165 }
8166
8167 static int test_rm_2 (void)
8168 {
8169   /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
8170   {
8171     char device[] = "/dev/sda";
8172     device[5] = devchar;
8173     int r;
8174     suppress_error = 0;
8175     r = guestfs_blockdev_setrw (g, device);
8176     if (r == -1)
8177       return -1;
8178   }
8179   {
8180     int r;
8181     suppress_error = 0;
8182     r = guestfs_umount_all (g);
8183     if (r == -1)
8184       return -1;
8185   }
8186   {
8187     int r;
8188     suppress_error = 0;
8189     r = guestfs_lvm_remove_all (g);
8190     if (r == -1)
8191       return -1;
8192   }
8193   {
8194     char device[] = "/dev/sda";
8195     device[5] = devchar;
8196     char lines_0[] = ",";
8197     char *lines[] = {
8198       lines_0,
8199       NULL
8200     };
8201     int r;
8202     suppress_error = 0;
8203     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8204     if (r == -1)
8205       return -1;
8206   }
8207   {
8208     char fstype[] = "ext2";
8209     char device[] = "/dev/sda1";
8210     device[5] = devchar;
8211     int r;
8212     suppress_error = 0;
8213     r = guestfs_mkfs (g, fstype, device);
8214     if (r == -1)
8215       return -1;
8216   }
8217   {
8218     char device[] = "/dev/sda1";
8219     device[5] = devchar;
8220     char mountpoint[] = "/";
8221     int r;
8222     suppress_error = 0;
8223     r = guestfs_mount (g, device, mountpoint);
8224     if (r == -1)
8225       return -1;
8226   }
8227   /* TestLastFail for rm (2) */
8228   {
8229     char path[] = "/new";
8230     int r;
8231     suppress_error = 0;
8232     r = guestfs_mkdir (g, path);
8233     if (r == -1)
8234       return -1;
8235   }
8236   {
8237     char path[] = "/new";
8238     int r;
8239     suppress_error = 1;
8240     r = guestfs_rm (g, path);
8241     if (r != -1)
8242       return -1;
8243   }
8244   return 0;
8245 }
8246
8247 static int test_read_lines_0 (void)
8248 {
8249   /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
8250   {
8251     char device[] = "/dev/sda";
8252     device[5] = devchar;
8253     int r;
8254     suppress_error = 0;
8255     r = guestfs_blockdev_setrw (g, device);
8256     if (r == -1)
8257       return -1;
8258   }
8259   {
8260     int r;
8261     suppress_error = 0;
8262     r = guestfs_umount_all (g);
8263     if (r == -1)
8264       return -1;
8265   }
8266   {
8267     int r;
8268     suppress_error = 0;
8269     r = guestfs_lvm_remove_all (g);
8270     if (r == -1)
8271       return -1;
8272   }
8273   {
8274     char device[] = "/dev/sda";
8275     device[5] = devchar;
8276     char lines_0[] = ",";
8277     char *lines[] = {
8278       lines_0,
8279       NULL
8280     };
8281     int r;
8282     suppress_error = 0;
8283     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8284     if (r == -1)
8285       return -1;
8286   }
8287   {
8288     char fstype[] = "ext2";
8289     char device[] = "/dev/sda1";
8290     device[5] = devchar;
8291     int r;
8292     suppress_error = 0;
8293     r = guestfs_mkfs (g, fstype, device);
8294     if (r == -1)
8295       return -1;
8296   }
8297   {
8298     char device[] = "/dev/sda1";
8299     device[5] = devchar;
8300     char mountpoint[] = "/";
8301     int r;
8302     suppress_error = 0;
8303     r = guestfs_mount (g, device, mountpoint);
8304     if (r == -1)
8305       return -1;
8306   }
8307   /* TestOutputList for read_lines (0) */
8308   {
8309     char path[] = "/new";
8310     char content[] = "line1\r\nline2\nline3";
8311     int r;
8312     suppress_error = 0;
8313     r = guestfs_write_file (g, path, content, 0);
8314     if (r == -1)
8315       return -1;
8316   }
8317   {
8318     char path[] = "/new";
8319     char **r;
8320     int i;
8321     suppress_error = 0;
8322     r = guestfs_read_lines (g, path);
8323     if (r == NULL)
8324       return -1;
8325     if (!r[0]) {
8326       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8327       print_strings (r);
8328       return -1;
8329     }
8330     {
8331       char expected[] = "line1";
8332       if (strcmp (r[0], expected) != 0) {
8333         fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8334         return -1;
8335       }
8336     }
8337     if (!r[1]) {
8338       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8339       print_strings (r);
8340       return -1;
8341     }
8342     {
8343       char expected[] = "line2";
8344       if (strcmp (r[1], expected) != 0) {
8345         fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8346         return -1;
8347       }
8348     }
8349     if (!r[2]) {
8350       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8351       print_strings (r);
8352       return -1;
8353     }
8354     {
8355       char expected[] = "line3";
8356       if (strcmp (r[2], expected) != 0) {
8357         fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8358         return -1;
8359       }
8360     }
8361     if (r[3] != NULL) {
8362       fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
8363       print_strings (r);
8364       return -1;
8365     }
8366     for (i = 0; r[i] != NULL; ++i)
8367       free (r[i]);
8368     free (r);
8369   }
8370   return 0;
8371 }
8372
8373 static int test_read_lines_1 (void)
8374 {
8375   /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
8376   {
8377     char device[] = "/dev/sda";
8378     device[5] = devchar;
8379     int r;
8380     suppress_error = 0;
8381     r = guestfs_blockdev_setrw (g, device);
8382     if (r == -1)
8383       return -1;
8384   }
8385   {
8386     int r;
8387     suppress_error = 0;
8388     r = guestfs_umount_all (g);
8389     if (r == -1)
8390       return -1;
8391   }
8392   {
8393     int r;
8394     suppress_error = 0;
8395     r = guestfs_lvm_remove_all (g);
8396     if (r == -1)
8397       return -1;
8398   }
8399   {
8400     char device[] = "/dev/sda";
8401     device[5] = devchar;
8402     char lines_0[] = ",";
8403     char *lines[] = {
8404       lines_0,
8405       NULL
8406     };
8407     int r;
8408     suppress_error = 0;
8409     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8410     if (r == -1)
8411       return -1;
8412   }
8413   {
8414     char fstype[] = "ext2";
8415     char device[] = "/dev/sda1";
8416     device[5] = devchar;
8417     int r;
8418     suppress_error = 0;
8419     r = guestfs_mkfs (g, fstype, device);
8420     if (r == -1)
8421       return -1;
8422   }
8423   {
8424     char device[] = "/dev/sda1";
8425     device[5] = devchar;
8426     char mountpoint[] = "/";
8427     int r;
8428     suppress_error = 0;
8429     r = guestfs_mount (g, device, mountpoint);
8430     if (r == -1)
8431       return -1;
8432   }
8433   /* TestOutputList for read_lines (1) */
8434   {
8435     char path[] = "/new";
8436     char content[] = "";
8437     int r;
8438     suppress_error = 0;
8439     r = guestfs_write_file (g, path, content, 0);
8440     if (r == -1)
8441       return -1;
8442   }
8443   {
8444     char path[] = "/new";
8445     char **r;
8446     int i;
8447     suppress_error = 0;
8448     r = guestfs_read_lines (g, path);
8449     if (r == NULL)
8450       return -1;
8451     if (r[0] != NULL) {
8452       fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
8453       print_strings (r);
8454       return -1;
8455     }
8456     for (i = 0; r[i] != NULL; ++i)
8457       free (r[i]);
8458     free (r);
8459   }
8460   return 0;
8461 }
8462
8463 static int test_lvs_0 (void)
8464 {
8465   /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
8466   {
8467     char device[] = "/dev/sda";
8468     device[5] = devchar;
8469     int r;
8470     suppress_error = 0;
8471     r = guestfs_blockdev_setrw (g, device);
8472     if (r == -1)
8473       return -1;
8474   }
8475   {
8476     int r;
8477     suppress_error = 0;
8478     r = guestfs_umount_all (g);
8479     if (r == -1)
8480       return -1;
8481   }
8482   {
8483     int r;
8484     suppress_error = 0;
8485     r = guestfs_lvm_remove_all (g);
8486     if (r == -1)
8487       return -1;
8488   }
8489   {
8490     char device[] = "/dev/sda";
8491     device[5] = devchar;
8492     char lines_0[] = ",";
8493     char *lines[] = {
8494       lines_0,
8495       NULL
8496     };
8497     int r;
8498     suppress_error = 0;
8499     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8500     if (r == -1)
8501       return -1;
8502   }
8503   {
8504     char device[] = "/dev/sda1";
8505     device[5] = devchar;
8506     int r;
8507     suppress_error = 0;
8508     r = guestfs_pvcreate (g, device);
8509     if (r == -1)
8510       return -1;
8511   }
8512   {
8513     char volgroup[] = "VG";
8514     char physvols_0[] = "/dev/sda1";
8515     physvols_0[5] = devchar;
8516     char *physvols[] = {
8517       physvols_0,
8518       NULL
8519     };
8520     int r;
8521     suppress_error = 0;
8522     r = guestfs_vgcreate (g, volgroup, physvols);
8523     if (r == -1)
8524       return -1;
8525   }
8526   {
8527     char logvol[] = "LV";
8528     char volgroup[] = "VG";
8529     int r;
8530     suppress_error = 0;
8531     r = guestfs_lvcreate (g, logvol, volgroup, 8);
8532     if (r == -1)
8533       return -1;
8534   }
8535   {
8536     char fstype[] = "ext2";
8537     char device[] = "/dev/VG/LV";
8538     int r;
8539     suppress_error = 0;
8540     r = guestfs_mkfs (g, fstype, device);
8541     if (r == -1)
8542       return -1;
8543   }
8544   {
8545     char device[] = "/dev/VG/LV";
8546     char mountpoint[] = "/";
8547     int r;
8548     suppress_error = 0;
8549     r = guestfs_mount (g, device, mountpoint);
8550     if (r == -1)
8551       return -1;
8552   }
8553   /* TestOutputList for lvs (0) */
8554   {
8555     char **r;
8556     int i;
8557     suppress_error = 0;
8558     r = guestfs_lvs (g);
8559     if (r == NULL)
8560       return -1;
8561     if (!r[0]) {
8562       fprintf (stderr, "test_lvs_0: short list returned from command\n");
8563       print_strings (r);
8564       return -1;
8565     }
8566     {
8567       char expected[] = "/dev/VG/LV";
8568       if (strcmp (r[0], expected) != 0) {
8569         fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8570         return -1;
8571       }
8572     }
8573     if (r[1] != NULL) {
8574       fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
8575       print_strings (r);
8576       return -1;
8577     }
8578     for (i = 0; r[i] != NULL; ++i)
8579       free (r[i]);
8580     free (r);
8581   }
8582   return 0;
8583 }
8584
8585 static int test_lvs_1 (void)
8586 {
8587   /* InitEmpty for lvs (1) */
8588   {
8589     char device[] = "/dev/sda";
8590     device[5] = devchar;
8591     int r;
8592     suppress_error = 0;
8593     r = guestfs_blockdev_setrw (g, device);
8594     if (r == -1)
8595       return -1;
8596   }
8597   {
8598     int r;
8599     suppress_error = 0;
8600     r = guestfs_umount_all (g);
8601     if (r == -1)
8602       return -1;
8603   }
8604   {
8605     int r;
8606     suppress_error = 0;
8607     r = guestfs_lvm_remove_all (g);
8608     if (r == -1)
8609       return -1;
8610   }
8611   /* TestOutputList for lvs (1) */
8612   {
8613     char device[] = "/dev/sda";
8614     device[5] = devchar;
8615     char lines_0[] = ",10";
8616     char lines_1[] = ",20";
8617     char lines_2[] = ",";
8618     char *lines[] = {
8619       lines_0,
8620       lines_1,
8621       lines_2,
8622       NULL
8623     };
8624     int r;
8625     suppress_error = 0;
8626     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8627     if (r == -1)
8628       return -1;
8629   }
8630   {
8631     char device[] = "/dev/sda1";
8632     device[5] = devchar;
8633     int r;
8634     suppress_error = 0;
8635     r = guestfs_pvcreate (g, device);
8636     if (r == -1)
8637       return -1;
8638   }
8639   {
8640     char device[] = "/dev/sda2";
8641     device[5] = devchar;
8642     int r;
8643     suppress_error = 0;
8644     r = guestfs_pvcreate (g, device);
8645     if (r == -1)
8646       return -1;
8647   }
8648   {
8649     char device[] = "/dev/sda3";
8650     device[5] = devchar;
8651     int r;
8652     suppress_error = 0;
8653     r = guestfs_pvcreate (g, device);
8654     if (r == -1)
8655       return -1;
8656   }
8657   {
8658     char volgroup[] = "VG1";
8659     char physvols_0[] = "/dev/sda1";
8660     physvols_0[5] = devchar;
8661     char physvols_1[] = "/dev/sda2";
8662     physvols_1[5] = devchar;
8663     char *physvols[] = {
8664       physvols_0,
8665       physvols_1,
8666       NULL
8667     };
8668     int r;
8669     suppress_error = 0;
8670     r = guestfs_vgcreate (g, volgroup, physvols);
8671     if (r == -1)
8672       return -1;
8673   }
8674   {
8675     char volgroup[] = "VG2";
8676     char physvols_0[] = "/dev/sda3";
8677     physvols_0[5] = devchar;
8678     char *physvols[] = {
8679       physvols_0,
8680       NULL
8681     };
8682     int r;
8683     suppress_error = 0;
8684     r = guestfs_vgcreate (g, volgroup, physvols);
8685     if (r == -1)
8686       return -1;
8687   }
8688   {
8689     char logvol[] = "LV1";
8690     char volgroup[] = "VG1";
8691     int r;
8692     suppress_error = 0;
8693     r = guestfs_lvcreate (g, logvol, volgroup, 50);
8694     if (r == -1)
8695       return -1;
8696   }
8697   {
8698     char logvol[] = "LV2";
8699     char volgroup[] = "VG1";
8700     int r;
8701     suppress_error = 0;
8702     r = guestfs_lvcreate (g, logvol, volgroup, 50);
8703     if (r == -1)
8704       return -1;
8705   }
8706   {
8707     char logvol[] = "LV3";
8708     char volgroup[] = "VG2";
8709     int r;
8710     suppress_error = 0;
8711     r = guestfs_lvcreate (g, logvol, volgroup, 50);
8712     if (r == -1)
8713       return -1;
8714   }
8715   {
8716     char **r;
8717     int i;
8718     suppress_error = 0;
8719     r = guestfs_lvs (g);
8720     if (r == NULL)
8721       return -1;
8722     if (!r[0]) {
8723       fprintf (stderr, "test_lvs_1: short list returned from command\n");
8724       print_strings (r);
8725       return -1;
8726     }
8727     {
8728       char expected[] = "/dev/VG1/LV1";
8729       if (strcmp (r[0], expected) != 0) {
8730         fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8731         return -1;
8732       }
8733     }
8734     if (!r[1]) {
8735       fprintf (stderr, "test_lvs_1: short list returned from command\n");
8736       print_strings (r);
8737       return -1;
8738     }
8739     {
8740       char expected[] = "/dev/VG1/LV2";
8741       if (strcmp (r[1], expected) != 0) {
8742         fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8743         return -1;
8744       }
8745     }
8746     if (!r[2]) {
8747       fprintf (stderr, "test_lvs_1: short list returned from command\n");
8748       print_strings (r);
8749       return -1;
8750     }
8751     {
8752       char expected[] = "/dev/VG2/LV3";
8753       if (strcmp (r[2], expected) != 0) {
8754         fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8755         return -1;
8756       }
8757     }
8758     if (r[3] != NULL) {
8759       fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
8760       print_strings (r);
8761       return -1;
8762     }
8763     for (i = 0; r[i] != NULL; ++i)
8764       free (r[i]);
8765     free (r);
8766   }
8767   return 0;
8768 }
8769
8770 static int test_vgs_0 (void)
8771 {
8772   /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
8773   {
8774     char device[] = "/dev/sda";
8775     device[5] = devchar;
8776     int r;
8777     suppress_error = 0;
8778     r = guestfs_blockdev_setrw (g, device);
8779     if (r == -1)
8780       return -1;
8781   }
8782   {
8783     int r;
8784     suppress_error = 0;
8785     r = guestfs_umount_all (g);
8786     if (r == -1)
8787       return -1;
8788   }
8789   {
8790     int r;
8791     suppress_error = 0;
8792     r = guestfs_lvm_remove_all (g);
8793     if (r == -1)
8794       return -1;
8795   }
8796   {
8797     char device[] = "/dev/sda";
8798     device[5] = devchar;
8799     char lines_0[] = ",";
8800     char *lines[] = {
8801       lines_0,
8802       NULL
8803     };
8804     int r;
8805     suppress_error = 0;
8806     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8807     if (r == -1)
8808       return -1;
8809   }
8810   {
8811     char device[] = "/dev/sda1";
8812     device[5] = devchar;
8813     int r;
8814     suppress_error = 0;
8815     r = guestfs_pvcreate (g, device);
8816     if (r == -1)
8817       return -1;
8818   }
8819   {
8820     char volgroup[] = "VG";
8821     char physvols_0[] = "/dev/sda1";
8822     physvols_0[5] = devchar;
8823     char *physvols[] = {
8824       physvols_0,
8825       NULL
8826     };
8827     int r;
8828     suppress_error = 0;
8829     r = guestfs_vgcreate (g, volgroup, physvols);
8830     if (r == -1)
8831       return -1;
8832   }
8833   {
8834     char logvol[] = "LV";
8835     char volgroup[] = "VG";
8836     int r;
8837     suppress_error = 0;
8838     r = guestfs_lvcreate (g, logvol, volgroup, 8);
8839     if (r == -1)
8840       return -1;
8841   }
8842   {
8843     char fstype[] = "ext2";
8844     char device[] = "/dev/VG/LV";
8845     int r;
8846     suppress_error = 0;
8847     r = guestfs_mkfs (g, fstype, device);
8848     if (r == -1)
8849       return -1;
8850   }
8851   {
8852     char device[] = "/dev/VG/LV";
8853     char mountpoint[] = "/";
8854     int r;
8855     suppress_error = 0;
8856     r = guestfs_mount (g, device, mountpoint);
8857     if (r == -1)
8858       return -1;
8859   }
8860   /* TestOutputList for vgs (0) */
8861   {
8862     char **r;
8863     int i;
8864     suppress_error = 0;
8865     r = guestfs_vgs (g);
8866     if (r == NULL)
8867       return -1;
8868     if (!r[0]) {
8869       fprintf (stderr, "test_vgs_0: short list returned from command\n");
8870       print_strings (r);
8871       return -1;
8872     }
8873     {
8874       char expected[] = "VG";
8875       if (strcmp (r[0], expected) != 0) {
8876         fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8877         return -1;
8878       }
8879     }
8880     if (r[1] != NULL) {
8881       fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
8882       print_strings (r);
8883       return -1;
8884     }
8885     for (i = 0; r[i] != NULL; ++i)
8886       free (r[i]);
8887     free (r);
8888   }
8889   return 0;
8890 }
8891
8892 static int test_vgs_1 (void)
8893 {
8894   /* InitEmpty for vgs (1) */
8895   {
8896     char device[] = "/dev/sda";
8897     device[5] = devchar;
8898     int r;
8899     suppress_error = 0;
8900     r = guestfs_blockdev_setrw (g, device);
8901     if (r == -1)
8902       return -1;
8903   }
8904   {
8905     int r;
8906     suppress_error = 0;
8907     r = guestfs_umount_all (g);
8908     if (r == -1)
8909       return -1;
8910   }
8911   {
8912     int r;
8913     suppress_error = 0;
8914     r = guestfs_lvm_remove_all (g);
8915     if (r == -1)
8916       return -1;
8917   }
8918   /* TestOutputList for vgs (1) */
8919   {
8920     char device[] = "/dev/sda";
8921     device[5] = devchar;
8922     char lines_0[] = ",10";
8923     char lines_1[] = ",20";
8924     char lines_2[] = ",";
8925     char *lines[] = {
8926       lines_0,
8927       lines_1,
8928       lines_2,
8929       NULL
8930     };
8931     int r;
8932     suppress_error = 0;
8933     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8934     if (r == -1)
8935       return -1;
8936   }
8937   {
8938     char device[] = "/dev/sda1";
8939     device[5] = devchar;
8940     int r;
8941     suppress_error = 0;
8942     r = guestfs_pvcreate (g, device);
8943     if (r == -1)
8944       return -1;
8945   }
8946   {
8947     char device[] = "/dev/sda2";
8948     device[5] = devchar;
8949     int r;
8950     suppress_error = 0;
8951     r = guestfs_pvcreate (g, device);
8952     if (r == -1)
8953       return -1;
8954   }
8955   {
8956     char device[] = "/dev/sda3";
8957     device[5] = devchar;
8958     int r;
8959     suppress_error = 0;
8960     r = guestfs_pvcreate (g, device);
8961     if (r == -1)
8962       return -1;
8963   }
8964   {
8965     char volgroup[] = "VG1";
8966     char physvols_0[] = "/dev/sda1";
8967     physvols_0[5] = devchar;
8968     char physvols_1[] = "/dev/sda2";
8969     physvols_1[5] = devchar;
8970     char *physvols[] = {
8971       physvols_0,
8972       physvols_1,
8973       NULL
8974     };
8975     int r;
8976     suppress_error = 0;
8977     r = guestfs_vgcreate (g, volgroup, physvols);
8978     if (r == -1)
8979       return -1;
8980   }
8981   {
8982     char volgroup[] = "VG2";
8983     char physvols_0[] = "/dev/sda3";
8984     physvols_0[5] = devchar;
8985     char *physvols[] = {
8986       physvols_0,
8987       NULL
8988     };
8989     int r;
8990     suppress_error = 0;
8991     r = guestfs_vgcreate (g, volgroup, physvols);
8992     if (r == -1)
8993       return -1;
8994   }
8995   {
8996     char **r;
8997     int i;
8998     suppress_error = 0;
8999     r = guestfs_vgs (g);
9000     if (r == NULL)
9001       return -1;
9002     if (!r[0]) {
9003       fprintf (stderr, "test_vgs_1: short list returned from command\n");
9004       print_strings (r);
9005       return -1;
9006     }
9007     {
9008       char expected[] = "VG1";
9009       if (strcmp (r[0], expected) != 0) {
9010         fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9011         return -1;
9012       }
9013     }
9014     if (!r[1]) {
9015       fprintf (stderr, "test_vgs_1: short list returned from command\n");
9016       print_strings (r);
9017       return -1;
9018     }
9019     {
9020       char expected[] = "VG2";
9021       if (strcmp (r[1], expected) != 0) {
9022         fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9023         return -1;
9024       }
9025     }
9026     if (r[2] != NULL) {
9027       fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
9028       print_strings (r);
9029       return -1;
9030     }
9031     for (i = 0; r[i] != NULL; ++i)
9032       free (r[i]);
9033     free (r);
9034   }
9035   return 0;
9036 }
9037
9038 static int test_pvs_0 (void)
9039 {
9040   /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
9041   {
9042     char device[] = "/dev/sda";
9043     device[5] = devchar;
9044     int r;
9045     suppress_error = 0;
9046     r = guestfs_blockdev_setrw (g, device);
9047     if (r == -1)
9048       return -1;
9049   }
9050   {
9051     int r;
9052     suppress_error = 0;
9053     r = guestfs_umount_all (g);
9054     if (r == -1)
9055       return -1;
9056   }
9057   {
9058     int r;
9059     suppress_error = 0;
9060     r = guestfs_lvm_remove_all (g);
9061     if (r == -1)
9062       return -1;
9063   }
9064   {
9065     char device[] = "/dev/sda";
9066     device[5] = devchar;
9067     char lines_0[] = ",";
9068     char *lines[] = {
9069       lines_0,
9070       NULL
9071     };
9072     int r;
9073     suppress_error = 0;
9074     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9075     if (r == -1)
9076       return -1;
9077   }
9078   {
9079     char device[] = "/dev/sda1";
9080     device[5] = devchar;
9081     int r;
9082     suppress_error = 0;
9083     r = guestfs_pvcreate (g, device);
9084     if (r == -1)
9085       return -1;
9086   }
9087   {
9088     char volgroup[] = "VG";
9089     char physvols_0[] = "/dev/sda1";
9090     physvols_0[5] = devchar;
9091     char *physvols[] = {
9092       physvols_0,
9093       NULL
9094     };
9095     int r;
9096     suppress_error = 0;
9097     r = guestfs_vgcreate (g, volgroup, physvols);
9098     if (r == -1)
9099       return -1;
9100   }
9101   {
9102     char logvol[] = "LV";
9103     char volgroup[] = "VG";
9104     int r;
9105     suppress_error = 0;
9106     r = guestfs_lvcreate (g, logvol, volgroup, 8);
9107     if (r == -1)
9108       return -1;
9109   }
9110   {
9111     char fstype[] = "ext2";
9112     char device[] = "/dev/VG/LV";
9113     int r;
9114     suppress_error = 0;
9115     r = guestfs_mkfs (g, fstype, device);
9116     if (r == -1)
9117       return -1;
9118   }
9119   {
9120     char device[] = "/dev/VG/LV";
9121     char mountpoint[] = "/";
9122     int r;
9123     suppress_error = 0;
9124     r = guestfs_mount (g, device, mountpoint);
9125     if (r == -1)
9126       return -1;
9127   }
9128   /* TestOutputList for pvs (0) */
9129   {
9130     char **r;
9131     int i;
9132     suppress_error = 0;
9133     r = guestfs_pvs (g);
9134     if (r == NULL)
9135       return -1;
9136     if (!r[0]) {
9137       fprintf (stderr, "test_pvs_0: short list returned from command\n");
9138       print_strings (r);
9139       return -1;
9140     }
9141     {
9142       char expected[] = "/dev/sda1";
9143       expected[5] = devchar;
9144       if (strcmp (r[0], expected) != 0) {
9145         fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9146         return -1;
9147       }
9148     }
9149     if (r[1] != NULL) {
9150       fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
9151       print_strings (r);
9152       return -1;
9153     }
9154     for (i = 0; r[i] != NULL; ++i)
9155       free (r[i]);
9156     free (r);
9157   }
9158   return 0;
9159 }
9160
9161 static int test_pvs_1 (void)
9162 {
9163   /* InitEmpty for pvs (1) */
9164   {
9165     char device[] = "/dev/sda";
9166     device[5] = devchar;
9167     int r;
9168     suppress_error = 0;
9169     r = guestfs_blockdev_setrw (g, device);
9170     if (r == -1)
9171       return -1;
9172   }
9173   {
9174     int r;
9175     suppress_error = 0;
9176     r = guestfs_umount_all (g);
9177     if (r == -1)
9178       return -1;
9179   }
9180   {
9181     int r;
9182     suppress_error = 0;
9183     r = guestfs_lvm_remove_all (g);
9184     if (r == -1)
9185       return -1;
9186   }
9187   /* TestOutputList for pvs (1) */
9188   {
9189     char device[] = "/dev/sda";
9190     device[5] = devchar;
9191     char lines_0[] = ",10";
9192     char lines_1[] = ",20";
9193     char lines_2[] = ",";
9194     char *lines[] = {
9195       lines_0,
9196       lines_1,
9197       lines_2,
9198       NULL
9199     };
9200     int r;
9201     suppress_error = 0;
9202     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9203     if (r == -1)
9204       return -1;
9205   }
9206   {
9207     char device[] = "/dev/sda1";
9208     device[5] = devchar;
9209     int r;
9210     suppress_error = 0;
9211     r = guestfs_pvcreate (g, device);
9212     if (r == -1)
9213       return -1;
9214   }
9215   {
9216     char device[] = "/dev/sda2";
9217     device[5] = devchar;
9218     int r;
9219     suppress_error = 0;
9220     r = guestfs_pvcreate (g, device);
9221     if (r == -1)
9222       return -1;
9223   }
9224   {
9225     char device[] = "/dev/sda3";
9226     device[5] = devchar;
9227     int r;
9228     suppress_error = 0;
9229     r = guestfs_pvcreate (g, device);
9230     if (r == -1)
9231       return -1;
9232   }
9233   {
9234     char **r;
9235     int i;
9236     suppress_error = 0;
9237     r = guestfs_pvs (g);
9238     if (r == NULL)
9239       return -1;
9240     if (!r[0]) {
9241       fprintf (stderr, "test_pvs_1: short list returned from command\n");
9242       print_strings (r);
9243       return -1;
9244     }
9245     {
9246       char expected[] = "/dev/sda1";
9247       expected[5] = devchar;
9248       if (strcmp (r[0], expected) != 0) {
9249         fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9250         return -1;
9251       }
9252     }
9253     if (!r[1]) {
9254       fprintf (stderr, "test_pvs_1: short list returned from command\n");
9255       print_strings (r);
9256       return -1;
9257     }
9258     {
9259       char expected[] = "/dev/sda2";
9260       expected[5] = devchar;
9261       if (strcmp (r[1], expected) != 0) {
9262         fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9263         return -1;
9264       }
9265     }
9266     if (!r[2]) {
9267       fprintf (stderr, "test_pvs_1: short list returned from command\n");
9268       print_strings (r);
9269       return -1;
9270     }
9271     {
9272       char expected[] = "/dev/sda3";
9273       expected[5] = devchar;
9274       if (strcmp (r[2], expected) != 0) {
9275         fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9276         return -1;
9277       }
9278     }
9279     if (r[3] != NULL) {
9280       fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
9281       print_strings (r);
9282       return -1;
9283     }
9284     for (i = 0; r[i] != NULL; ++i)
9285       free (r[i]);
9286     free (r);
9287   }
9288   return 0;
9289 }
9290
9291 static int test_list_partitions_0 (void)
9292 {
9293   /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
9294   {
9295     char device[] = "/dev/sda";
9296     device[5] = devchar;
9297     int r;
9298     suppress_error = 0;
9299     r = guestfs_blockdev_setrw (g, device);
9300     if (r == -1)
9301       return -1;
9302   }
9303   {
9304     int r;
9305     suppress_error = 0;
9306     r = guestfs_umount_all (g);
9307     if (r == -1)
9308       return -1;
9309   }
9310   {
9311     int r;
9312     suppress_error = 0;
9313     r = guestfs_lvm_remove_all (g);
9314     if (r == -1)
9315       return -1;
9316   }
9317   {
9318     char device[] = "/dev/sda";
9319     device[5] = devchar;
9320     char lines_0[] = ",";
9321     char *lines[] = {
9322       lines_0,
9323       NULL
9324     };
9325     int r;
9326     suppress_error = 0;
9327     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9328     if (r == -1)
9329       return -1;
9330   }
9331   {
9332     char fstype[] = "ext2";
9333     char device[] = "/dev/sda1";
9334     device[5] = devchar;
9335     int r;
9336     suppress_error = 0;
9337     r = guestfs_mkfs (g, fstype, device);
9338     if (r == -1)
9339       return -1;
9340   }
9341   {
9342     char device[] = "/dev/sda1";
9343     device[5] = devchar;
9344     char mountpoint[] = "/";
9345     int r;
9346     suppress_error = 0;
9347     r = guestfs_mount (g, device, mountpoint);
9348     if (r == -1)
9349       return -1;
9350   }
9351   /* TestOutputList for list_partitions (0) */
9352   {
9353     char **r;
9354     int i;
9355     suppress_error = 0;
9356     r = guestfs_list_partitions (g);
9357     if (r == NULL)
9358       return -1;
9359     if (!r[0]) {
9360       fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
9361       print_strings (r);
9362       return -1;
9363     }
9364     {
9365       char expected[] = "/dev/sda1";
9366       expected[5] = devchar;
9367       if (strcmp (r[0], expected) != 0) {
9368         fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9369         return -1;
9370       }
9371     }
9372     if (r[1] != NULL) {
9373       fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
9374       print_strings (r);
9375       return -1;
9376     }
9377     for (i = 0; r[i] != NULL; ++i)
9378       free (r[i]);
9379     free (r);
9380   }
9381   return 0;
9382 }
9383
9384 static int test_list_partitions_1 (void)
9385 {
9386   /* InitEmpty for list_partitions (1) */
9387   {
9388     char device[] = "/dev/sda";
9389     device[5] = devchar;
9390     int r;
9391     suppress_error = 0;
9392     r = guestfs_blockdev_setrw (g, device);
9393     if (r == -1)
9394       return -1;
9395   }
9396   {
9397     int r;
9398     suppress_error = 0;
9399     r = guestfs_umount_all (g);
9400     if (r == -1)
9401       return -1;
9402   }
9403   {
9404     int r;
9405     suppress_error = 0;
9406     r = guestfs_lvm_remove_all (g);
9407     if (r == -1)
9408       return -1;
9409   }
9410   /* TestOutputList for list_partitions (1) */
9411   {
9412     char device[] = "/dev/sda";
9413     device[5] = devchar;
9414     char lines_0[] = ",10";
9415     char lines_1[] = ",20";
9416     char lines_2[] = ",";
9417     char *lines[] = {
9418       lines_0,
9419       lines_1,
9420       lines_2,
9421       NULL
9422     };
9423     int r;
9424     suppress_error = 0;
9425     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9426     if (r == -1)
9427       return -1;
9428   }
9429   {
9430     char **r;
9431     int i;
9432     suppress_error = 0;
9433     r = guestfs_list_partitions (g);
9434     if (r == NULL)
9435       return -1;
9436     if (!r[0]) {
9437       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9438       print_strings (r);
9439       return -1;
9440     }
9441     {
9442       char expected[] = "/dev/sda1";
9443       expected[5] = devchar;
9444       if (strcmp (r[0], expected) != 0) {
9445         fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9446         return -1;
9447       }
9448     }
9449     if (!r[1]) {
9450       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9451       print_strings (r);
9452       return -1;
9453     }
9454     {
9455       char expected[] = "/dev/sda2";
9456       expected[5] = devchar;
9457       if (strcmp (r[1], expected) != 0) {
9458         fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9459         return -1;
9460       }
9461     }
9462     if (!r[2]) {
9463       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9464       print_strings (r);
9465       return -1;
9466     }
9467     {
9468       char expected[] = "/dev/sda3";
9469       expected[5] = devchar;
9470       if (strcmp (r[2], expected) != 0) {
9471         fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9472         return -1;
9473       }
9474     }
9475     if (r[3] != NULL) {
9476       fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
9477       print_strings (r);
9478       return -1;
9479     }
9480     for (i = 0; r[i] != NULL; ++i)
9481       free (r[i]);
9482     free (r);
9483   }
9484   return 0;
9485 }
9486
9487 static int test_list_devices_0 (void)
9488 {
9489   /* InitEmpty for list_devices (0) */
9490   {
9491     char device[] = "/dev/sda";
9492     device[5] = devchar;
9493     int r;
9494     suppress_error = 0;
9495     r = guestfs_blockdev_setrw (g, device);
9496     if (r == -1)
9497       return -1;
9498   }
9499   {
9500     int r;
9501     suppress_error = 0;
9502     r = guestfs_umount_all (g);
9503     if (r == -1)
9504       return -1;
9505   }
9506   {
9507     int r;
9508     suppress_error = 0;
9509     r = guestfs_lvm_remove_all (g);
9510     if (r == -1)
9511       return -1;
9512   }
9513   /* TestOutputList for list_devices (0) */
9514   {
9515     char **r;
9516     int i;
9517     suppress_error = 0;
9518     r = guestfs_list_devices (g);
9519     if (r == NULL)
9520       return -1;
9521     if (!r[0]) {
9522       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9523       print_strings (r);
9524       return -1;
9525     }
9526     {
9527       char expected[] = "/dev/sda";
9528       expected[5] = devchar;
9529       if (strcmp (r[0], expected) != 0) {
9530         fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9531         return -1;
9532       }
9533     }
9534     if (!r[1]) {
9535       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9536       print_strings (r);
9537       return -1;
9538     }
9539     {
9540       char expected[] = "/dev/sdb";
9541       expected[5] = devchar;
9542       if (strcmp (r[1], expected) != 0) {
9543         fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9544         return -1;
9545       }
9546     }
9547     if (!r[2]) {
9548       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9549       print_strings (r);
9550       return -1;
9551     }
9552     {
9553       char expected[] = "/dev/sdc";
9554       expected[5] = devchar;
9555       if (strcmp (r[2], expected) != 0) {
9556         fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9557         return -1;
9558       }
9559     }
9560     if (r[3] != NULL) {
9561       fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
9562       print_strings (r);
9563       return -1;
9564     }
9565     for (i = 0; r[i] != NULL; ++i)
9566       free (r[i]);
9567     free (r);
9568   }
9569   return 0;
9570 }
9571
9572 static int test_ls_0 (void)
9573 {
9574   /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
9575   {
9576     char device[] = "/dev/sda";
9577     device[5] = devchar;
9578     int r;
9579     suppress_error = 0;
9580     r = guestfs_blockdev_setrw (g, device);
9581     if (r == -1)
9582       return -1;
9583   }
9584   {
9585     int r;
9586     suppress_error = 0;
9587     r = guestfs_umount_all (g);
9588     if (r == -1)
9589       return -1;
9590   }
9591   {
9592     int r;
9593     suppress_error = 0;
9594     r = guestfs_lvm_remove_all (g);
9595     if (r == -1)
9596       return -1;
9597   }
9598   {
9599     char device[] = "/dev/sda";
9600     device[5] = devchar;
9601     char lines_0[] = ",";
9602     char *lines[] = {
9603       lines_0,
9604       NULL
9605     };
9606     int r;
9607     suppress_error = 0;
9608     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9609     if (r == -1)
9610       return -1;
9611   }
9612   {
9613     char fstype[] = "ext2";
9614     char device[] = "/dev/sda1";
9615     device[5] = devchar;
9616     int r;
9617     suppress_error = 0;
9618     r = guestfs_mkfs (g, fstype, device);
9619     if (r == -1)
9620       return -1;
9621   }
9622   {
9623     char device[] = "/dev/sda1";
9624     device[5] = devchar;
9625     char mountpoint[] = "/";
9626     int r;
9627     suppress_error = 0;
9628     r = guestfs_mount (g, device, mountpoint);
9629     if (r == -1)
9630       return -1;
9631   }
9632   /* TestOutputList for ls (0) */
9633   {
9634     char path[] = "/new";
9635     int r;
9636     suppress_error = 0;
9637     r = guestfs_touch (g, path);
9638     if (r == -1)
9639       return -1;
9640   }
9641   {
9642     char path[] = "/newer";
9643     int r;
9644     suppress_error = 0;
9645     r = guestfs_touch (g, path);
9646     if (r == -1)
9647       return -1;
9648   }
9649   {
9650     char path[] = "/newest";
9651     int r;
9652     suppress_error = 0;
9653     r = guestfs_touch (g, path);
9654     if (r == -1)
9655       return -1;
9656   }
9657   {
9658     char directory[] = "/";
9659     char **r;
9660     int i;
9661     suppress_error = 0;
9662     r = guestfs_ls (g, directory);
9663     if (r == NULL)
9664       return -1;
9665     if (!r[0]) {
9666       fprintf (stderr, "test_ls_0: short list returned from command\n");
9667       print_strings (r);
9668       return -1;
9669     }
9670     {
9671       char expected[] = "lost+found";
9672       if (strcmp (r[0], expected) != 0) {
9673         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9674         return -1;
9675       }
9676     }
9677     if (!r[1]) {
9678       fprintf (stderr, "test_ls_0: short list returned from command\n");
9679       print_strings (r);
9680       return -1;
9681     }
9682     {
9683       char expected[] = "new";
9684       if (strcmp (r[1], expected) != 0) {
9685         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9686         return -1;
9687       }
9688     }
9689     if (!r[2]) {
9690       fprintf (stderr, "test_ls_0: short list returned from command\n");
9691       print_strings (r);
9692       return -1;
9693     }
9694     {
9695       char expected[] = "newer";
9696       if (strcmp (r[2], expected) != 0) {
9697         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9698         return -1;
9699       }
9700     }
9701     if (!r[3]) {
9702       fprintf (stderr, "test_ls_0: short list returned from command\n");
9703       print_strings (r);
9704       return -1;
9705     }
9706     {
9707       char expected[] = "newest";
9708       if (strcmp (r[3], expected) != 0) {
9709         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
9710         return -1;
9711       }
9712     }
9713     if (r[4] != NULL) {
9714       fprintf (stderr, "test_ls_0: extra elements returned from command\n");
9715       print_strings (r);
9716       return -1;
9717     }
9718     for (i = 0; r[i] != NULL; ++i)
9719       free (r[i]);
9720     free (r);
9721   }
9722   return 0;
9723 }
9724
9725 static int test_cat_0 (void)
9726 {
9727   /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
9728   {
9729     char device[] = "/dev/sda";
9730     device[5] = devchar;
9731     int r;
9732     suppress_error = 0;
9733     r = guestfs_blockdev_setrw (g, device);
9734     if (r == -1)
9735       return -1;
9736   }
9737   {
9738     int r;
9739     suppress_error = 0;
9740     r = guestfs_umount_all (g);
9741     if (r == -1)
9742       return -1;
9743   }
9744   {
9745     int r;
9746     suppress_error = 0;
9747     r = guestfs_lvm_remove_all (g);
9748     if (r == -1)
9749       return -1;
9750   }
9751   {
9752     char device[] = "/dev/sda";
9753     device[5] = devchar;
9754     char lines_0[] = ",";
9755     char *lines[] = {
9756       lines_0,
9757       NULL
9758     };
9759     int r;
9760     suppress_error = 0;
9761     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9762     if (r == -1)
9763       return -1;
9764   }
9765   {
9766     char fstype[] = "ext2";
9767     char device[] = "/dev/sda1";
9768     device[5] = devchar;
9769     int r;
9770     suppress_error = 0;
9771     r = guestfs_mkfs (g, fstype, device);
9772     if (r == -1)
9773       return -1;
9774   }
9775   {
9776     char device[] = "/dev/sda1";
9777     device[5] = devchar;
9778     char mountpoint[] = "/";
9779     int r;
9780     suppress_error = 0;
9781     r = guestfs_mount (g, device, mountpoint);
9782     if (r == -1)
9783       return -1;
9784   }
9785   /* TestOutput for cat (0) */
9786   char expected[] = "new file contents";
9787   {
9788     char path[] = "/new";
9789     char content[] = "new file contents";
9790     int r;
9791     suppress_error = 0;
9792     r = guestfs_write_file (g, path, content, 0);
9793     if (r == -1)
9794       return -1;
9795   }
9796   {
9797     char path[] = "/new";
9798     char *r;
9799     suppress_error = 0;
9800     r = guestfs_cat (g, path);
9801     if (r == NULL)
9802       return -1;
9803     if (strcmp (r, expected) != 0) {
9804       fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
9805       return -1;
9806     }
9807     free (r);
9808   }
9809   return 0;
9810 }
9811
9812 static int test_touch_0 (void)
9813 {
9814   /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
9815   {
9816     char device[] = "/dev/sda";
9817     device[5] = devchar;
9818     int r;
9819     suppress_error = 0;
9820     r = guestfs_blockdev_setrw (g, device);
9821     if (r == -1)
9822       return -1;
9823   }
9824   {
9825     int r;
9826     suppress_error = 0;
9827     r = guestfs_umount_all (g);
9828     if (r == -1)
9829       return -1;
9830   }
9831   {
9832     int r;
9833     suppress_error = 0;
9834     r = guestfs_lvm_remove_all (g);
9835     if (r == -1)
9836       return -1;
9837   }
9838   {
9839     char device[] = "/dev/sda";
9840     device[5] = devchar;
9841     char lines_0[] = ",";
9842     char *lines[] = {
9843       lines_0,
9844       NULL
9845     };
9846     int r;
9847     suppress_error = 0;
9848     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9849     if (r == -1)
9850       return -1;
9851   }
9852   {
9853     char fstype[] = "ext2";
9854     char device[] = "/dev/sda1";
9855     device[5] = devchar;
9856     int r;
9857     suppress_error = 0;
9858     r = guestfs_mkfs (g, fstype, device);
9859     if (r == -1)
9860       return -1;
9861   }
9862   {
9863     char device[] = "/dev/sda1";
9864     device[5] = devchar;
9865     char mountpoint[] = "/";
9866     int r;
9867     suppress_error = 0;
9868     r = guestfs_mount (g, device, mountpoint);
9869     if (r == -1)
9870       return -1;
9871   }
9872   /* TestOutputTrue for touch (0) */
9873   {
9874     char path[] = "/new";
9875     int r;
9876     suppress_error = 0;
9877     r = guestfs_touch (g, path);
9878     if (r == -1)
9879       return -1;
9880   }
9881   {
9882     char path[] = "/new";
9883     int r;
9884     suppress_error = 0;
9885     r = guestfs_exists (g, path);
9886     if (r == -1)
9887       return -1;
9888     if (!r) {
9889       fprintf (stderr, "test_touch_0: expected true, got false\n");
9890       return -1;
9891     }
9892   }
9893   return 0;
9894 }
9895
9896 static int test_sync_0 (void)
9897 {
9898   /* InitEmpty for sync (0) */
9899   {
9900     char device[] = "/dev/sda";
9901     device[5] = devchar;
9902     int r;
9903     suppress_error = 0;
9904     r = guestfs_blockdev_setrw (g, device);
9905     if (r == -1)
9906       return -1;
9907   }
9908   {
9909     int r;
9910     suppress_error = 0;
9911     r = guestfs_umount_all (g);
9912     if (r == -1)
9913       return -1;
9914   }
9915   {
9916     int r;
9917     suppress_error = 0;
9918     r = guestfs_lvm_remove_all (g);
9919     if (r == -1)
9920       return -1;
9921   }
9922   /* TestRun for sync (0) */
9923   {
9924     int r;
9925     suppress_error = 0;
9926     r = guestfs_sync (g);
9927     if (r == -1)
9928       return -1;
9929   }
9930   return 0;
9931 }
9932
9933 static int test_mount_0 (void)
9934 {
9935   /* InitEmpty for mount (0) */
9936   {
9937     char device[] = "/dev/sda";
9938     device[5] = devchar;
9939     int r;
9940     suppress_error = 0;
9941     r = guestfs_blockdev_setrw (g, device);
9942     if (r == -1)
9943       return -1;
9944   }
9945   {
9946     int r;
9947     suppress_error = 0;
9948     r = guestfs_umount_all (g);
9949     if (r == -1)
9950       return -1;
9951   }
9952   {
9953     int r;
9954     suppress_error = 0;
9955     r = guestfs_lvm_remove_all (g);
9956     if (r == -1)
9957       return -1;
9958   }
9959   /* TestOutput for mount (0) */
9960   char expected[] = "new file contents";
9961   {
9962     char device[] = "/dev/sda";
9963     device[5] = devchar;
9964     char lines_0[] = ",";
9965     char *lines[] = {
9966       lines_0,
9967       NULL
9968     };
9969     int r;
9970     suppress_error = 0;
9971     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9972     if (r == -1)
9973       return -1;
9974   }
9975   {
9976     char fstype[] = "ext2";
9977     char device[] = "/dev/sda1";
9978     device[5] = devchar;
9979     int r;
9980     suppress_error = 0;
9981     r = guestfs_mkfs (g, fstype, device);
9982     if (r == -1)
9983       return -1;
9984   }
9985   {
9986     char device[] = "/dev/sda1";
9987     device[5] = devchar;
9988     char mountpoint[] = "/";
9989     int r;
9990     suppress_error = 0;
9991     r = guestfs_mount (g, device, mountpoint);
9992     if (r == -1)
9993       return -1;
9994   }
9995   {
9996     char path[] = "/new";
9997     char content[] = "new file contents";
9998     int r;
9999     suppress_error = 0;
10000     r = guestfs_write_file (g, path, content, 0);
10001     if (r == -1)
10002       return -1;
10003   }
10004   {
10005     char path[] = "/new";
10006     char *r;
10007     suppress_error = 0;
10008     r = guestfs_cat (g, path);
10009     if (r == NULL)
10010       return -1;
10011     if (strcmp (r, expected) != 0) {
10012       fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
10013       return -1;
10014     }
10015     free (r);
10016   }
10017   return 0;
10018 }
10019
10020 int main (int argc, char *argv[])
10021 {
10022   char c = 0;
10023   int failed = 0;
10024   const char *srcdir;
10025   const char *filename;
10026   int fd, i;
10027   int nr_tests, test_num = 0;
10028   char **devs;
10029
10030   no_test_warnings ();
10031
10032   g = guestfs_create ();
10033   if (g == NULL) {
10034     printf ("guestfs_create FAILED\n");
10035     exit (1);
10036   }
10037
10038   guestfs_set_error_handler (g, print_error, NULL);
10039
10040   srcdir = getenv ("srcdir");
10041   if (!srcdir) srcdir = ".";
10042   chdir (srcdir);
10043   guestfs_set_path (g, ".");
10044
10045   filename = "test1.img";
10046   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10047   if (fd == -1) {
10048     perror (filename);
10049     exit (1);
10050   }
10051   if (lseek (fd, 524288000, SEEK_SET) == -1) {
10052     perror ("lseek");
10053     close (fd);
10054     unlink (filename);
10055     exit (1);
10056   }
10057   if (write (fd, &c, 1) == -1) {
10058     perror ("write");
10059     close (fd);
10060     unlink (filename);
10061     exit (1);
10062   }
10063   if (close (fd) == -1) {
10064     perror (filename);
10065     unlink (filename);
10066     exit (1);
10067   }
10068   if (guestfs_add_drive (g, filename) == -1) {
10069     printf ("guestfs_add_drive %s FAILED\n", filename);
10070     exit (1);
10071   }
10072
10073   filename = "test2.img";
10074   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10075   if (fd == -1) {
10076     perror (filename);
10077     exit (1);
10078   }
10079   if (lseek (fd, 52428800, SEEK_SET) == -1) {
10080     perror ("lseek");
10081     close (fd);
10082     unlink (filename);
10083     exit (1);
10084   }
10085   if (write (fd, &c, 1) == -1) {
10086     perror ("write");
10087     close (fd);
10088     unlink (filename);
10089     exit (1);
10090   }
10091   if (close (fd) == -1) {
10092     perror (filename);
10093     unlink (filename);
10094     exit (1);
10095   }
10096   if (guestfs_add_drive (g, filename) == -1) {
10097     printf ("guestfs_add_drive %s FAILED\n", filename);
10098     exit (1);
10099   }
10100
10101   filename = "test3.img";
10102   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10103   if (fd == -1) {
10104     perror (filename);
10105     exit (1);
10106   }
10107   if (lseek (fd, 10485760, SEEK_SET) == -1) {
10108     perror ("lseek");
10109     close (fd);
10110     unlink (filename);
10111     exit (1);
10112   }
10113   if (write (fd, &c, 1) == -1) {
10114     perror ("write");
10115     close (fd);
10116     unlink (filename);
10117     exit (1);
10118   }
10119   if (close (fd) == -1) {
10120     perror (filename);
10121     unlink (filename);
10122     exit (1);
10123   }
10124   if (guestfs_add_drive (g, filename) == -1) {
10125     printf ("guestfs_add_drive %s FAILED\n", filename);
10126     exit (1);
10127   }
10128
10129   if (guestfs_launch (g) == -1) {
10130     printf ("guestfs_launch FAILED\n");
10131     exit (1);
10132   }
10133   if (guestfs_wait_ready (g) == -1) {
10134     printf ("guestfs_wait_ready FAILED\n");
10135     exit (1);
10136   }
10137
10138   /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
10139    * names.  This changed between RHEL 5 and RHEL 6 so we have to
10140    * support both.
10141    */
10142   devs = guestfs_list_devices (g);
10143   if (devs == NULL || devs[0] == NULL) {
10144     printf ("guestfs_list_devices FAILED\n");
10145     exit (1);
10146   }
10147   if (strncmp (devs[0], "/dev/sd", 7) == 0)
10148     devchar = 's';
10149   else if (strncmp (devs[0], "/dev/hd", 7) == 0)
10150     devchar = 'h';
10151   else {
10152     printf ("guestfs_list_devices returned unexpected string '%s'\n",
10153             devs[0]);
10154     exit (1);
10155   }
10156   for (i = 0; devs[i] != NULL; ++i)
10157     free (devs[i]);
10158   free (devs);
10159
10160   nr_tests = 110;
10161
10162   test_num++;
10163   printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
10164   if (test_hexdump_0 () == -1) {
10165     printf ("test_hexdump_0 FAILED\n");
10166     failed++;
10167   }
10168   test_num++;
10169   printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
10170   if (test_strings_e_0 () == -1) {
10171     printf ("test_strings_e_0 FAILED\n");
10172     failed++;
10173   }
10174   test_num++;
10175   printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
10176   if (test_strings_0 () == -1) {
10177     printf ("test_strings_0 FAILED\n");
10178     failed++;
10179   }
10180   test_num++;
10181   printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
10182   if (test_equal_0 () == -1) {
10183     printf ("test_equal_0 FAILED\n");
10184     failed++;
10185   }
10186   test_num++;
10187   printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
10188   if (test_equal_1 () == -1) {
10189     printf ("test_equal_1 FAILED\n");
10190     failed++;
10191   }
10192   test_num++;
10193   printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
10194   if (test_equal_2 () == -1) {
10195     printf ("test_equal_2 FAILED\n");
10196     failed++;
10197   }
10198   test_num++;
10199   printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
10200   if (test_ping_daemon_0 () == -1) {
10201     printf ("test_ping_daemon_0 FAILED\n");
10202     failed++;
10203   }
10204   test_num++;
10205   printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
10206   if (test_dmesg_0 () == -1) {
10207     printf ("test_dmesg_0 FAILED\n");
10208     failed++;
10209   }
10210   test_num++;
10211   printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
10212   if (test_drop_caches_0 () == -1) {
10213     printf ("test_drop_caches_0 FAILED\n");
10214     failed++;
10215   }
10216   test_num++;
10217   printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
10218   if (test_mv_0 () == -1) {
10219     printf ("test_mv_0 FAILED\n");
10220     failed++;
10221   }
10222   test_num++;
10223   printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
10224   if (test_mv_1 () == -1) {
10225     printf ("test_mv_1 FAILED\n");
10226     failed++;
10227   }
10228   test_num++;
10229   printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
10230   if (test_cp_a_0 () == -1) {
10231     printf ("test_cp_a_0 FAILED\n");
10232     failed++;
10233   }
10234   test_num++;
10235   printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
10236   if (test_cp_0 () == -1) {
10237     printf ("test_cp_0 FAILED\n");
10238     failed++;
10239   }
10240   test_num++;
10241   printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
10242   if (test_cp_1 () == -1) {
10243     printf ("test_cp_1 FAILED\n");
10244     failed++;
10245   }
10246   test_num++;
10247   printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
10248   if (test_cp_2 () == -1) {
10249     printf ("test_cp_2 FAILED\n");
10250     failed++;
10251   }
10252   test_num++;
10253   printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
10254   if (test_grub_install_0 () == -1) {
10255     printf ("test_grub_install_0 FAILED\n");
10256     failed++;
10257   }
10258   test_num++;
10259   printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
10260   if (test_zero_0 () == -1) {
10261     printf ("test_zero_0 FAILED\n");
10262     failed++;
10263   }
10264   test_num++;
10265   printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
10266   if (test_fsck_0 () == -1) {
10267     printf ("test_fsck_0 FAILED\n");
10268     failed++;
10269   }
10270   test_num++;
10271   printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
10272   if (test_fsck_1 () == -1) {
10273     printf ("test_fsck_1 FAILED\n");
10274     failed++;
10275   }
10276   test_num++;
10277   printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
10278   if (test_set_e2uuid_0 () == -1) {
10279     printf ("test_set_e2uuid_0 FAILED\n");
10280     failed++;
10281   }
10282   test_num++;
10283   printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
10284   if (test_set_e2uuid_1 () == -1) {
10285     printf ("test_set_e2uuid_1 FAILED\n");
10286     failed++;
10287   }
10288   test_num++;
10289   printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
10290   if (test_set_e2uuid_2 () == -1) {
10291     printf ("test_set_e2uuid_2 FAILED\n");
10292     failed++;
10293   }
10294   test_num++;
10295   printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
10296   if (test_set_e2uuid_3 () == -1) {
10297     printf ("test_set_e2uuid_3 FAILED\n");
10298     failed++;
10299   }
10300   test_num++;
10301   printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
10302   if (test_set_e2label_0 () == -1) {
10303     printf ("test_set_e2label_0 FAILED\n");
10304     failed++;
10305   }
10306   test_num++;
10307   printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
10308   if (test_pvremove_0 () == -1) {
10309     printf ("test_pvremove_0 FAILED\n");
10310     failed++;
10311   }
10312   test_num++;
10313   printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
10314   if (test_pvremove_1 () == -1) {
10315     printf ("test_pvremove_1 FAILED\n");
10316     failed++;
10317   }
10318   test_num++;
10319   printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
10320   if (test_pvremove_2 () == -1) {
10321     printf ("test_pvremove_2 FAILED\n");
10322     failed++;
10323   }
10324   test_num++;
10325   printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
10326   if (test_vgremove_0 () == -1) {
10327     printf ("test_vgremove_0 FAILED\n");
10328     failed++;
10329   }
10330   test_num++;
10331   printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
10332   if (test_vgremove_1 () == -1) {
10333     printf ("test_vgremove_1 FAILED\n");
10334     failed++;
10335   }
10336   test_num++;
10337   printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
10338   if (test_lvremove_0 () == -1) {
10339     printf ("test_lvremove_0 FAILED\n");
10340     failed++;
10341   }
10342   test_num++;
10343   printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
10344   if (test_lvremove_1 () == -1) {
10345     printf ("test_lvremove_1 FAILED\n");
10346     failed++;
10347   }
10348   test_num++;
10349   printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
10350   if (test_lvremove_2 () == -1) {
10351     printf ("test_lvremove_2 FAILED\n");
10352     failed++;
10353   }
10354   test_num++;
10355   printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
10356   if (test_mount_ro_0 () == -1) {
10357     printf ("test_mount_ro_0 FAILED\n");
10358     failed++;
10359   }
10360   test_num++;
10361   printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
10362   if (test_mount_ro_1 () == -1) {
10363     printf ("test_mount_ro_1 FAILED\n");
10364     failed++;
10365   }
10366   test_num++;
10367   printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
10368   if (test_tgz_in_0 () == -1) {
10369     printf ("test_tgz_in_0 FAILED\n");
10370     failed++;
10371   }
10372   test_num++;
10373   printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
10374   if (test_tar_in_0 () == -1) {
10375     printf ("test_tar_in_0 FAILED\n");
10376     failed++;
10377   }
10378   test_num++;
10379   printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
10380   if (test_checksum_0 () == -1) {
10381     printf ("test_checksum_0 FAILED\n");
10382     failed++;
10383   }
10384   test_num++;
10385   printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
10386   if (test_checksum_1 () == -1) {
10387     printf ("test_checksum_1 FAILED\n");
10388     failed++;
10389   }
10390   test_num++;
10391   printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
10392   if (test_checksum_2 () == -1) {
10393     printf ("test_checksum_2 FAILED\n");
10394     failed++;
10395   }
10396   test_num++;
10397   printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
10398   if (test_checksum_3 () == -1) {
10399     printf ("test_checksum_3 FAILED\n");
10400     failed++;
10401   }
10402   test_num++;
10403   printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
10404   if (test_checksum_4 () == -1) {
10405     printf ("test_checksum_4 FAILED\n");
10406     failed++;
10407   }
10408   test_num++;
10409   printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
10410   if (test_checksum_5 () == -1) {
10411     printf ("test_checksum_5 FAILED\n");
10412     failed++;
10413   }
10414   test_num++;
10415   printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
10416   if (test_checksum_6 () == -1) {
10417     printf ("test_checksum_6 FAILED\n");
10418     failed++;
10419   }
10420   test_num++;
10421   printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
10422   if (test_checksum_7 () == -1) {
10423     printf ("test_checksum_7 FAILED\n");
10424     failed++;
10425   }
10426   test_num++;
10427   printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
10428   if (test_download_0 () == -1) {
10429     printf ("test_download_0 FAILED\n");
10430     failed++;
10431   }
10432   test_num++;
10433   printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
10434   if (test_upload_0 () == -1) {
10435     printf ("test_upload_0 FAILED\n");
10436     failed++;
10437   }
10438   test_num++;
10439   printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
10440   if (test_blockdev_rereadpt_0 () == -1) {
10441     printf ("test_blockdev_rereadpt_0 FAILED\n");
10442     failed++;
10443   }
10444   test_num++;
10445   printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
10446   if (test_blockdev_flushbufs_0 () == -1) {
10447     printf ("test_blockdev_flushbufs_0 FAILED\n");
10448     failed++;
10449   }
10450   test_num++;
10451   printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
10452   if (test_blockdev_getsize64_0 () == -1) {
10453     printf ("test_blockdev_getsize64_0 FAILED\n");
10454     failed++;
10455   }
10456   test_num++;
10457   printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
10458   if (test_blockdev_getsz_0 () == -1) {
10459     printf ("test_blockdev_getsz_0 FAILED\n");
10460     failed++;
10461   }
10462   test_num++;
10463   printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
10464   if (test_blockdev_getbsz_0 () == -1) {
10465     printf ("test_blockdev_getbsz_0 FAILED\n");
10466     failed++;
10467   }
10468   test_num++;
10469   printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
10470   if (test_blockdev_getss_0 () == -1) {
10471     printf ("test_blockdev_getss_0 FAILED\n");
10472     failed++;
10473   }
10474   test_num++;
10475   printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
10476   if (test_blockdev_getro_0 () == -1) {
10477     printf ("test_blockdev_getro_0 FAILED\n");
10478     failed++;
10479   }
10480   test_num++;
10481   printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
10482   if (test_blockdev_setrw_0 () == -1) {
10483     printf ("test_blockdev_setrw_0 FAILED\n");
10484     failed++;
10485   }
10486   test_num++;
10487   printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
10488   if (test_blockdev_setro_0 () == -1) {
10489     printf ("test_blockdev_setro_0 FAILED\n");
10490     failed++;
10491   }
10492   test_num++;
10493   printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
10494   if (test_statvfs_0 () == -1) {
10495     printf ("test_statvfs_0 FAILED\n");
10496     failed++;
10497   }
10498   test_num++;
10499   printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
10500   if (test_lstat_0 () == -1) {
10501     printf ("test_lstat_0 FAILED\n");
10502     failed++;
10503   }
10504   test_num++;
10505   printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
10506   if (test_stat_0 () == -1) {
10507     printf ("test_stat_0 FAILED\n");
10508     failed++;
10509   }
10510   test_num++;
10511   printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
10512   if (test_file_0 () == -1) {
10513     printf ("test_file_0 FAILED\n");
10514     failed++;
10515   }
10516   test_num++;
10517   printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
10518   if (test_file_1 () == -1) {
10519     printf ("test_file_1 FAILED\n");
10520     failed++;
10521   }
10522   test_num++;
10523   printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
10524   if (test_file_2 () == -1) {
10525     printf ("test_file_2 FAILED\n");
10526     failed++;
10527   }
10528   test_num++;
10529   printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
10530   if (test_umount_all_0 () == -1) {
10531     printf ("test_umount_all_0 FAILED\n");
10532     failed++;
10533   }
10534   test_num++;
10535   printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
10536   if (test_umount_all_1 () == -1) {
10537     printf ("test_umount_all_1 FAILED\n");
10538     failed++;
10539   }
10540   test_num++;
10541   printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
10542   if (test_mounts_0 () == -1) {
10543     printf ("test_mounts_0 FAILED\n");
10544     failed++;
10545   }
10546   test_num++;
10547   printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
10548   if (test_umount_0 () == -1) {
10549     printf ("test_umount_0 FAILED\n");
10550     failed++;
10551   }
10552   test_num++;
10553   printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
10554   if (test_umount_1 () == -1) {
10555     printf ("test_umount_1 FAILED\n");
10556     failed++;
10557   }
10558   test_num++;
10559   printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
10560   if (test_write_file_0 () == -1) {
10561     printf ("test_write_file_0 FAILED\n");
10562     failed++;
10563   }
10564   test_num++;
10565   printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
10566   if (test_write_file_1 () == -1) {
10567     printf ("test_write_file_1 FAILED\n");
10568     failed++;
10569   }
10570   test_num++;
10571   printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
10572   if (test_write_file_2 () == -1) {
10573     printf ("test_write_file_2 FAILED\n");
10574     failed++;
10575   }
10576   test_num++;
10577   printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
10578   if (test_write_file_3 () == -1) {
10579     printf ("test_write_file_3 FAILED\n");
10580     failed++;
10581   }
10582   test_num++;
10583   printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
10584   if (test_write_file_4 () == -1) {
10585     printf ("test_write_file_4 FAILED\n");
10586     failed++;
10587   }
10588   test_num++;
10589   printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
10590   if (test_write_file_5 () == -1) {
10591     printf ("test_write_file_5 FAILED\n");
10592     failed++;
10593   }
10594   test_num++;
10595   printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
10596   if (test_mkfs_0 () == -1) {
10597     printf ("test_mkfs_0 FAILED\n");
10598     failed++;
10599   }
10600   test_num++;
10601   printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
10602   if (test_lvcreate_0 () == -1) {
10603     printf ("test_lvcreate_0 FAILED\n");
10604     failed++;
10605   }
10606   test_num++;
10607   printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
10608   if (test_vgcreate_0 () == -1) {
10609     printf ("test_vgcreate_0 FAILED\n");
10610     failed++;
10611   }
10612   test_num++;
10613   printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
10614   if (test_pvcreate_0 () == -1) {
10615     printf ("test_pvcreate_0 FAILED\n");
10616     failed++;
10617   }
10618   test_num++;
10619   printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
10620   if (test_is_dir_0 () == -1) {
10621     printf ("test_is_dir_0 FAILED\n");
10622     failed++;
10623   }
10624   test_num++;
10625   printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
10626   if (test_is_dir_1 () == -1) {
10627     printf ("test_is_dir_1 FAILED\n");
10628     failed++;
10629   }
10630   test_num++;
10631   printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
10632   if (test_is_file_0 () == -1) {
10633     printf ("test_is_file_0 FAILED\n");
10634     failed++;
10635   }
10636   test_num++;
10637   printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
10638   if (test_is_file_1 () == -1) {
10639     printf ("test_is_file_1 FAILED\n");
10640     failed++;
10641   }
10642   test_num++;
10643   printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
10644   if (test_exists_0 () == -1) {
10645     printf ("test_exists_0 FAILED\n");
10646     failed++;
10647   }
10648   test_num++;
10649   printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
10650   if (test_exists_1 () == -1) {
10651     printf ("test_exists_1 FAILED\n");
10652     failed++;
10653   }
10654   test_num++;
10655   printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
10656   if (test_mkdir_p_0 () == -1) {
10657     printf ("test_mkdir_p_0 FAILED\n");
10658     failed++;
10659   }
10660   test_num++;
10661   printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
10662   if (test_mkdir_p_1 () == -1) {
10663     printf ("test_mkdir_p_1 FAILED\n");
10664     failed++;
10665   }
10666   test_num++;
10667   printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
10668   if (test_mkdir_p_2 () == -1) {
10669     printf ("test_mkdir_p_2 FAILED\n");
10670     failed++;
10671   }
10672   test_num++;
10673   printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
10674   if (test_mkdir_0 () == -1) {
10675     printf ("test_mkdir_0 FAILED\n");
10676     failed++;
10677   }
10678   test_num++;
10679   printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
10680   if (test_mkdir_1 () == -1) {
10681     printf ("test_mkdir_1 FAILED\n");
10682     failed++;
10683   }
10684   test_num++;
10685   printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
10686   if (test_rm_rf_0 () == -1) {
10687     printf ("test_rm_rf_0 FAILED\n");
10688     failed++;
10689   }
10690   test_num++;
10691   printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
10692   if (test_rmdir_0 () == -1) {
10693     printf ("test_rmdir_0 FAILED\n");
10694     failed++;
10695   }
10696   test_num++;
10697   printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
10698   if (test_rmdir_1 () == -1) {
10699     printf ("test_rmdir_1 FAILED\n");
10700     failed++;
10701   }
10702   test_num++;
10703   printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
10704   if (test_rmdir_2 () == -1) {
10705     printf ("test_rmdir_2 FAILED\n");
10706     failed++;
10707   }
10708   test_num++;
10709   printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
10710   if (test_rm_0 () == -1) {
10711     printf ("test_rm_0 FAILED\n");
10712     failed++;
10713   }
10714   test_num++;
10715   printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
10716   if (test_rm_1 () == -1) {
10717     printf ("test_rm_1 FAILED\n");
10718     failed++;
10719   }
10720   test_num++;
10721   printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
10722   if (test_rm_2 () == -1) {
10723     printf ("test_rm_2 FAILED\n");
10724     failed++;
10725   }
10726   test_num++;
10727   printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
10728   if (test_read_lines_0 () == -1) {
10729     printf ("test_read_lines_0 FAILED\n");
10730     failed++;
10731   }
10732   test_num++;
10733   printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
10734   if (test_read_lines_1 () == -1) {
10735     printf ("test_read_lines_1 FAILED\n");
10736     failed++;
10737   }
10738   test_num++;
10739   printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
10740   if (test_lvs_0 () == -1) {
10741     printf ("test_lvs_0 FAILED\n");
10742     failed++;
10743   }
10744   test_num++;
10745   printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
10746   if (test_lvs_1 () == -1) {
10747     printf ("test_lvs_1 FAILED\n");
10748     failed++;
10749   }
10750   test_num++;
10751   printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
10752   if (test_vgs_0 () == -1) {
10753     printf ("test_vgs_0 FAILED\n");
10754     failed++;
10755   }
10756   test_num++;
10757   printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
10758   if (test_vgs_1 () == -1) {
10759     printf ("test_vgs_1 FAILED\n");
10760     failed++;
10761   }
10762   test_num++;
10763   printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
10764   if (test_pvs_0 () == -1) {
10765     printf ("test_pvs_0 FAILED\n");
10766     failed++;
10767   }
10768   test_num++;
10769   printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
10770   if (test_pvs_1 () == -1) {
10771     printf ("test_pvs_1 FAILED\n");
10772     failed++;
10773   }
10774   test_num++;
10775   printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
10776   if (test_list_partitions_0 () == -1) {
10777     printf ("test_list_partitions_0 FAILED\n");
10778     failed++;
10779   }
10780   test_num++;
10781   printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
10782   if (test_list_partitions_1 () == -1) {
10783     printf ("test_list_partitions_1 FAILED\n");
10784     failed++;
10785   }
10786   test_num++;
10787   printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
10788   if (test_list_devices_0 () == -1) {
10789     printf ("test_list_devices_0 FAILED\n");
10790     failed++;
10791   }
10792   test_num++;
10793   printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
10794   if (test_ls_0 () == -1) {
10795     printf ("test_ls_0 FAILED\n");
10796     failed++;
10797   }
10798   test_num++;
10799   printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
10800   if (test_cat_0 () == -1) {
10801     printf ("test_cat_0 FAILED\n");
10802     failed++;
10803   }
10804   test_num++;
10805   printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
10806   if (test_touch_0 () == -1) {
10807     printf ("test_touch_0 FAILED\n");
10808     failed++;
10809   }
10810   test_num++;
10811   printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
10812   if (test_sync_0 () == -1) {
10813     printf ("test_sync_0 FAILED\n");
10814     failed++;
10815   }
10816   test_num++;
10817   printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
10818   if (test_mount_0 () == -1) {
10819     printf ("test_mount_0 FAILED\n");
10820     failed++;
10821   }
10822
10823   guestfs_close (g);
10824   unlink ("test1.img");
10825   unlink ("test2.img");
10826   unlink ("test3.img");
10827
10828   if (failed > 0) {
10829     printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);
10830     exit (1);
10831   }
10832
10833   exit (0);
10834 }