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