Generated code for drop-caches command.
[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 static void print_error (guestfs_h *g, void *data, const char *msg)
35 {
36   if (!suppress_error)
37     fprintf (stderr, "%s\n", msg);
38 }
39
40 static void print_strings (char * const * const argv)
41 {
42   int argc;
43
44   for (argc = 0; argv[argc] != NULL; ++argc)
45     printf ("\t%s\n", argv[argc]);
46 }
47
48 /*
49 static void print_table (char * const * const argv)
50 {
51   int i;
52
53   for (i = 0; argv[i] != NULL; i += 2)
54     printf ("%s: %s\n", argv[i], argv[i+1]);
55 }
56 */
57
58 static void no_test_warnings (void)
59 {
60   fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
61   fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
62   fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
63   fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
64   fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
65   fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
66   fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
67   fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
68   fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
69   fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
70   fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
71   fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
72   fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
73   fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
74   fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
75   fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
76   fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
77   fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
78   fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
79   fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
80   fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
81   fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
82   fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
83   fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
84   fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
85   fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
86   fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
87   fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
88   fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
89   fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
90   fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
91   fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
92   fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
93   fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
94   fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
95   fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
96   fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
97   fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
98   fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
99   fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
100   fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
101   fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
102   fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
103   fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
104   fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
105   fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
106   fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
107   fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
108   fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
109   fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
110   fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
111   fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
112   fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
113 }
114
115 static int test_drop_caches_0 (void)
116 {
117   /* InitEmpty for drop_caches (0) */
118   {
119     int r;
120     suppress_error = 0;
121     r = guestfs_umount_all (g);
122     if (r == -1)
123       return -1;
124   }
125   {
126     int r;
127     suppress_error = 0;
128     r = guestfs_lvm_remove_all (g);
129     if (r == -1)
130       return -1;
131   }
132   /* TestRun for drop_caches (0) */
133   {
134     int r;
135     suppress_error = 0;
136     r = guestfs_drop_caches (g, 3);
137     if (r == -1)
138       return -1;
139   }
140   return 0;
141 }
142
143 static int test_mv_0 (void)
144 {
145   /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
146   {
147     int r;
148     suppress_error = 0;
149     r = guestfs_umount_all (g);
150     if (r == -1)
151       return -1;
152   }
153   {
154     int r;
155     suppress_error = 0;
156     r = guestfs_lvm_remove_all (g);
157     if (r == -1)
158       return -1;
159   }
160   {
161     char *lines[] = {
162       ",",
163       NULL
164     };
165     int r;
166     suppress_error = 0;
167     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
168     if (r == -1)
169       return -1;
170   }
171   {
172     int r;
173     suppress_error = 0;
174     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
175     if (r == -1)
176       return -1;
177   }
178   {
179     int r;
180     suppress_error = 0;
181     r = guestfs_mount (g, "/dev/sda1", "/");
182     if (r == -1)
183       return -1;
184   }
185   /* TestOutput for mv (0) */
186   {
187     int r;
188     suppress_error = 0;
189     r = guestfs_write_file (g, "/old", "file content", 0);
190     if (r == -1)
191       return -1;
192   }
193   {
194     int r;
195     suppress_error = 0;
196     r = guestfs_mv (g, "/old", "/new");
197     if (r == -1)
198       return -1;
199   }
200   {
201     char *r;
202     suppress_error = 0;
203     r = guestfs_cat (g, "/new");
204     if (r == NULL)
205       return -1;
206     if (strcmp (r, "file content") != 0) {
207       fprintf (stderr, "test_mv_0: expected \"file content\" but got \"%s\"\n", r);
208       return -1;
209     }
210     free (r);
211   }
212   return 0;
213 }
214
215 static int test_mv_1 (void)
216 {
217   /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
218   {
219     int r;
220     suppress_error = 0;
221     r = guestfs_umount_all (g);
222     if (r == -1)
223       return -1;
224   }
225   {
226     int r;
227     suppress_error = 0;
228     r = guestfs_lvm_remove_all (g);
229     if (r == -1)
230       return -1;
231   }
232   {
233     char *lines[] = {
234       ",",
235       NULL
236     };
237     int r;
238     suppress_error = 0;
239     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
240     if (r == -1)
241       return -1;
242   }
243   {
244     int r;
245     suppress_error = 0;
246     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
247     if (r == -1)
248       return -1;
249   }
250   {
251     int r;
252     suppress_error = 0;
253     r = guestfs_mount (g, "/dev/sda1", "/");
254     if (r == -1)
255       return -1;
256   }
257   /* TestOutputFalse for mv (1) */
258   {
259     int r;
260     suppress_error = 0;
261     r = guestfs_write_file (g, "/old", "file content", 0);
262     if (r == -1)
263       return -1;
264   }
265   {
266     int r;
267     suppress_error = 0;
268     r = guestfs_mv (g, "/old", "/new");
269     if (r == -1)
270       return -1;
271   }
272   {
273     int r;
274     suppress_error = 0;
275     r = guestfs_is_file (g, "/old");
276     if (r == -1)
277       return -1;
278     if (r) {
279       fprintf (stderr, "test_mv_1: expected false, got true\n");
280       return -1;
281     }
282   }
283   return 0;
284 }
285
286 static int test_cp_a_0 (void)
287 {
288   /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
289   {
290     int r;
291     suppress_error = 0;
292     r = guestfs_umount_all (g);
293     if (r == -1)
294       return -1;
295   }
296   {
297     int r;
298     suppress_error = 0;
299     r = guestfs_lvm_remove_all (g);
300     if (r == -1)
301       return -1;
302   }
303   {
304     char *lines[] = {
305       ",",
306       NULL
307     };
308     int r;
309     suppress_error = 0;
310     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
311     if (r == -1)
312       return -1;
313   }
314   {
315     int r;
316     suppress_error = 0;
317     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
318     if (r == -1)
319       return -1;
320   }
321   {
322     int r;
323     suppress_error = 0;
324     r = guestfs_mount (g, "/dev/sda1", "/");
325     if (r == -1)
326       return -1;
327   }
328   /* TestOutput for cp_a (0) */
329   {
330     int r;
331     suppress_error = 0;
332     r = guestfs_mkdir (g, "/olddir");
333     if (r == -1)
334       return -1;
335   }
336   {
337     int r;
338     suppress_error = 0;
339     r = guestfs_mkdir (g, "/newdir");
340     if (r == -1)
341       return -1;
342   }
343   {
344     int r;
345     suppress_error = 0;
346     r = guestfs_write_file (g, "/olddir/file", "file content", 0);
347     if (r == -1)
348       return -1;
349   }
350   {
351     int r;
352     suppress_error = 0;
353     r = guestfs_cp_a (g, "/olddir", "/newdir");
354     if (r == -1)
355       return -1;
356   }
357   {
358     char *r;
359     suppress_error = 0;
360     r = guestfs_cat (g, "/newdir/olddir/file");
361     if (r == NULL)
362       return -1;
363     if (strcmp (r, "file content") != 0) {
364       fprintf (stderr, "test_cp_a_0: expected \"file content\" but got \"%s\"\n", r);
365       return -1;
366     }
367     free (r);
368   }
369   return 0;
370 }
371
372 static int test_cp_0 (void)
373 {
374   /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
375   {
376     int r;
377     suppress_error = 0;
378     r = guestfs_umount_all (g);
379     if (r == -1)
380       return -1;
381   }
382   {
383     int r;
384     suppress_error = 0;
385     r = guestfs_lvm_remove_all (g);
386     if (r == -1)
387       return -1;
388   }
389   {
390     char *lines[] = {
391       ",",
392       NULL
393     };
394     int r;
395     suppress_error = 0;
396     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
397     if (r == -1)
398       return -1;
399   }
400   {
401     int r;
402     suppress_error = 0;
403     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
404     if (r == -1)
405       return -1;
406   }
407   {
408     int r;
409     suppress_error = 0;
410     r = guestfs_mount (g, "/dev/sda1", "/");
411     if (r == -1)
412       return -1;
413   }
414   /* TestOutput for cp (0) */
415   {
416     int r;
417     suppress_error = 0;
418     r = guestfs_write_file (g, "/old", "file content", 0);
419     if (r == -1)
420       return -1;
421   }
422   {
423     int r;
424     suppress_error = 0;
425     r = guestfs_cp (g, "/old", "/new");
426     if (r == -1)
427       return -1;
428   }
429   {
430     char *r;
431     suppress_error = 0;
432     r = guestfs_cat (g, "/new");
433     if (r == NULL)
434       return -1;
435     if (strcmp (r, "file content") != 0) {
436       fprintf (stderr, "test_cp_0: expected \"file content\" but got \"%s\"\n", r);
437       return -1;
438     }
439     free (r);
440   }
441   return 0;
442 }
443
444 static int test_cp_1 (void)
445 {
446   /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
447   {
448     int r;
449     suppress_error = 0;
450     r = guestfs_umount_all (g);
451     if (r == -1)
452       return -1;
453   }
454   {
455     int r;
456     suppress_error = 0;
457     r = guestfs_lvm_remove_all (g);
458     if (r == -1)
459       return -1;
460   }
461   {
462     char *lines[] = {
463       ",",
464       NULL
465     };
466     int r;
467     suppress_error = 0;
468     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
469     if (r == -1)
470       return -1;
471   }
472   {
473     int r;
474     suppress_error = 0;
475     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
476     if (r == -1)
477       return -1;
478   }
479   {
480     int r;
481     suppress_error = 0;
482     r = guestfs_mount (g, "/dev/sda1", "/");
483     if (r == -1)
484       return -1;
485   }
486   /* TestOutputTrue for cp (1) */
487   {
488     int r;
489     suppress_error = 0;
490     r = guestfs_write_file (g, "/old", "file content", 0);
491     if (r == -1)
492       return -1;
493   }
494   {
495     int r;
496     suppress_error = 0;
497     r = guestfs_cp (g, "/old", "/new");
498     if (r == -1)
499       return -1;
500   }
501   {
502     int r;
503     suppress_error = 0;
504     r = guestfs_is_file (g, "/old");
505     if (r == -1)
506       return -1;
507     if (!r) {
508       fprintf (stderr, "test_cp_1: expected true, got false\n");
509       return -1;
510     }
511   }
512   return 0;
513 }
514
515 static int test_cp_2 (void)
516 {
517   /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
518   {
519     int r;
520     suppress_error = 0;
521     r = guestfs_umount_all (g);
522     if (r == -1)
523       return -1;
524   }
525   {
526     int r;
527     suppress_error = 0;
528     r = guestfs_lvm_remove_all (g);
529     if (r == -1)
530       return -1;
531   }
532   {
533     char *lines[] = {
534       ",",
535       NULL
536     };
537     int r;
538     suppress_error = 0;
539     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
540     if (r == -1)
541       return -1;
542   }
543   {
544     int r;
545     suppress_error = 0;
546     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
547     if (r == -1)
548       return -1;
549   }
550   {
551     int r;
552     suppress_error = 0;
553     r = guestfs_mount (g, "/dev/sda1", "/");
554     if (r == -1)
555       return -1;
556   }
557   /* TestOutput for cp (2) */
558   {
559     int r;
560     suppress_error = 0;
561     r = guestfs_write_file (g, "/old", "file content", 0);
562     if (r == -1)
563       return -1;
564   }
565   {
566     int r;
567     suppress_error = 0;
568     r = guestfs_mkdir (g, "/dir");
569     if (r == -1)
570       return -1;
571   }
572   {
573     int r;
574     suppress_error = 0;
575     r = guestfs_cp (g, "/old", "/dir/new");
576     if (r == -1)
577       return -1;
578   }
579   {
580     char *r;
581     suppress_error = 0;
582     r = guestfs_cat (g, "/dir/new");
583     if (r == NULL)
584       return -1;
585     if (strcmp (r, "file content") != 0) {
586       fprintf (stderr, "test_cp_2: expected \"file content\" but got \"%s\"\n", r);
587       return -1;
588     }
589     free (r);
590   }
591   return 0;
592 }
593
594 static int test_grub_install_0 (void)
595 {
596   /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
597   {
598     int r;
599     suppress_error = 0;
600     r = guestfs_umount_all (g);
601     if (r == -1)
602       return -1;
603   }
604   {
605     int r;
606     suppress_error = 0;
607     r = guestfs_lvm_remove_all (g);
608     if (r == -1)
609       return -1;
610   }
611   {
612     char *lines[] = {
613       ",",
614       NULL
615     };
616     int r;
617     suppress_error = 0;
618     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
619     if (r == -1)
620       return -1;
621   }
622   {
623     int r;
624     suppress_error = 0;
625     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
626     if (r == -1)
627       return -1;
628   }
629   {
630     int r;
631     suppress_error = 0;
632     r = guestfs_mount (g, "/dev/sda1", "/");
633     if (r == -1)
634       return -1;
635   }
636   /* TestOutputTrue for grub_install (0) */
637   {
638     int r;
639     suppress_error = 0;
640     r = guestfs_grub_install (g, "/", "/dev/sda1");
641     if (r == -1)
642       return -1;
643   }
644   {
645     int r;
646     suppress_error = 0;
647     r = guestfs_is_dir (g, "/boot");
648     if (r == -1)
649       return -1;
650     if (!r) {
651       fprintf (stderr, "test_grub_install_0: expected true, got false\n");
652       return -1;
653     }
654   }
655   return 0;
656 }
657
658 static int test_zero_0 (void)
659 {
660   /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
661   {
662     int r;
663     suppress_error = 0;
664     r = guestfs_umount_all (g);
665     if (r == -1)
666       return -1;
667   }
668   {
669     int r;
670     suppress_error = 0;
671     r = guestfs_lvm_remove_all (g);
672     if (r == -1)
673       return -1;
674   }
675   {
676     char *lines[] = {
677       ",",
678       NULL
679     };
680     int r;
681     suppress_error = 0;
682     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
683     if (r == -1)
684       return -1;
685   }
686   {
687     int r;
688     suppress_error = 0;
689     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
690     if (r == -1)
691       return -1;
692   }
693   {
694     int r;
695     suppress_error = 0;
696     r = guestfs_mount (g, "/dev/sda1", "/");
697     if (r == -1)
698       return -1;
699   }
700   /* TestOutput for zero (0) */
701   {
702     int r;
703     suppress_error = 0;
704     r = guestfs_umount (g, "/dev/sda1");
705     if (r == -1)
706       return -1;
707   }
708   {
709     int r;
710     suppress_error = 0;
711     r = guestfs_zero (g, "/dev/sda1");
712     if (r == -1)
713       return -1;
714   }
715   {
716     char *r;
717     suppress_error = 0;
718     r = guestfs_file (g, "/dev/sda1");
719     if (r == NULL)
720       return -1;
721     if (strcmp (r, "data") != 0) {
722       fprintf (stderr, "test_zero_0: expected \"data\" but got \"%s\"\n", r);
723       return -1;
724     }
725     free (r);
726   }
727   return 0;
728 }
729
730 static int test_fsck_0 (void)
731 {
732   /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
733   {
734     int r;
735     suppress_error = 0;
736     r = guestfs_umount_all (g);
737     if (r == -1)
738       return -1;
739   }
740   {
741     int r;
742     suppress_error = 0;
743     r = guestfs_lvm_remove_all (g);
744     if (r == -1)
745       return -1;
746   }
747   {
748     char *lines[] = {
749       ",",
750       NULL
751     };
752     int r;
753     suppress_error = 0;
754     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
755     if (r == -1)
756       return -1;
757   }
758   {
759     int r;
760     suppress_error = 0;
761     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
762     if (r == -1)
763       return -1;
764   }
765   {
766     int r;
767     suppress_error = 0;
768     r = guestfs_mount (g, "/dev/sda1", "/");
769     if (r == -1)
770       return -1;
771   }
772   /* TestOutputInt for fsck (0) */
773   {
774     int r;
775     suppress_error = 0;
776     r = guestfs_umount (g, "/dev/sda1");
777     if (r == -1)
778       return -1;
779   }
780   {
781     int r;
782     suppress_error = 0;
783     r = guestfs_fsck (g, "ext2", "/dev/sda1");
784     if (r == -1)
785       return -1;
786     if (r != 0) {
787       fprintf (stderr, "test_fsck_0: expected 0 but got %d\n",               (int) r);
788       return -1;
789     }
790   }
791   return 0;
792 }
793
794 static int test_fsck_1 (void)
795 {
796   /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
797   {
798     int r;
799     suppress_error = 0;
800     r = guestfs_umount_all (g);
801     if (r == -1)
802       return -1;
803   }
804   {
805     int r;
806     suppress_error = 0;
807     r = guestfs_lvm_remove_all (g);
808     if (r == -1)
809       return -1;
810   }
811   {
812     char *lines[] = {
813       ",",
814       NULL
815     };
816     int r;
817     suppress_error = 0;
818     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
819     if (r == -1)
820       return -1;
821   }
822   {
823     int r;
824     suppress_error = 0;
825     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
826     if (r == -1)
827       return -1;
828   }
829   {
830     int r;
831     suppress_error = 0;
832     r = guestfs_mount (g, "/dev/sda1", "/");
833     if (r == -1)
834       return -1;
835   }
836   /* TestOutputInt for fsck (1) */
837   {
838     int r;
839     suppress_error = 0;
840     r = guestfs_umount (g, "/dev/sda1");
841     if (r == -1)
842       return -1;
843   }
844   {
845     int r;
846     suppress_error = 0;
847     r = guestfs_zero (g, "/dev/sda1");
848     if (r == -1)
849       return -1;
850   }
851   {
852     int r;
853     suppress_error = 0;
854     r = guestfs_fsck (g, "ext2", "/dev/sda1");
855     if (r == -1)
856       return -1;
857     if (r != 8) {
858       fprintf (stderr, "test_fsck_1: expected 8 but got %d\n",               (int) r);
859       return -1;
860     }
861   }
862   return 0;
863 }
864
865 static int test_set_e2uuid_0 (void)
866 {
867   /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
868   {
869     int r;
870     suppress_error = 0;
871     r = guestfs_umount_all (g);
872     if (r == -1)
873       return -1;
874   }
875   {
876     int r;
877     suppress_error = 0;
878     r = guestfs_lvm_remove_all (g);
879     if (r == -1)
880       return -1;
881   }
882   {
883     char *lines[] = {
884       ",",
885       NULL
886     };
887     int r;
888     suppress_error = 0;
889     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
890     if (r == -1)
891       return -1;
892   }
893   {
894     int r;
895     suppress_error = 0;
896     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
897     if (r == -1)
898       return -1;
899   }
900   {
901     int r;
902     suppress_error = 0;
903     r = guestfs_mount (g, "/dev/sda1", "/");
904     if (r == -1)
905       return -1;
906   }
907   /* TestOutput for set_e2uuid (0) */
908   {
909     int r;
910     suppress_error = 0;
911     r = guestfs_set_e2uuid (g, "/dev/sda1", "a3a61220-882b-4f61-89f4-cf24dcc7297d");
912     if (r == -1)
913       return -1;
914   }
915   {
916     char *r;
917     suppress_error = 0;
918     r = guestfs_get_e2uuid (g, "/dev/sda1");
919     if (r == NULL)
920       return -1;
921     if (strcmp (r, "a3a61220-882b-4f61-89f4-cf24dcc7297d") != 0) {
922       fprintf (stderr, "test_set_e2uuid_0: expected \"a3a61220-882b-4f61-89f4-cf24dcc7297d\" but got \"%s\"\n", r);
923       return -1;
924     }
925     free (r);
926   }
927   return 0;
928 }
929
930 static int test_set_e2uuid_1 (void)
931 {
932   /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
933   {
934     int r;
935     suppress_error = 0;
936     r = guestfs_umount_all (g);
937     if (r == -1)
938       return -1;
939   }
940   {
941     int r;
942     suppress_error = 0;
943     r = guestfs_lvm_remove_all (g);
944     if (r == -1)
945       return -1;
946   }
947   {
948     char *lines[] = {
949       ",",
950       NULL
951     };
952     int r;
953     suppress_error = 0;
954     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
955     if (r == -1)
956       return -1;
957   }
958   {
959     int r;
960     suppress_error = 0;
961     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
962     if (r == -1)
963       return -1;
964   }
965   {
966     int r;
967     suppress_error = 0;
968     r = guestfs_mount (g, "/dev/sda1", "/");
969     if (r == -1)
970       return -1;
971   }
972   /* TestOutput for set_e2uuid (1) */
973   {
974     int r;
975     suppress_error = 0;
976     r = guestfs_set_e2uuid (g, "/dev/sda1", "clear");
977     if (r == -1)
978       return -1;
979   }
980   {
981     char *r;
982     suppress_error = 0;
983     r = guestfs_get_e2uuid (g, "/dev/sda1");
984     if (r == NULL)
985       return -1;
986     if (strcmp (r, "") != 0) {
987       fprintf (stderr, "test_set_e2uuid_1: expected \"\" but got \"%s\"\n", r);
988       return -1;
989     }
990     free (r);
991   }
992   return 0;
993 }
994
995 static int test_set_e2uuid_2 (void)
996 {
997   /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
998   {
999     int r;
1000     suppress_error = 0;
1001     r = guestfs_umount_all (g);
1002     if (r == -1)
1003       return -1;
1004   }
1005   {
1006     int r;
1007     suppress_error = 0;
1008     r = guestfs_lvm_remove_all (g);
1009     if (r == -1)
1010       return -1;
1011   }
1012   {
1013     char *lines[] = {
1014       ",",
1015       NULL
1016     };
1017     int r;
1018     suppress_error = 0;
1019     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1020     if (r == -1)
1021       return -1;
1022   }
1023   {
1024     int r;
1025     suppress_error = 0;
1026     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1027     if (r == -1)
1028       return -1;
1029   }
1030   {
1031     int r;
1032     suppress_error = 0;
1033     r = guestfs_mount (g, "/dev/sda1", "/");
1034     if (r == -1)
1035       return -1;
1036   }
1037   /* TestRun for set_e2uuid (2) */
1038   {
1039     int r;
1040     suppress_error = 0;
1041     r = guestfs_set_e2uuid (g, "/dev/sda1", "random");
1042     if (r == -1)
1043       return -1;
1044   }
1045   return 0;
1046 }
1047
1048 static int test_set_e2uuid_3 (void)
1049 {
1050   /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
1051   {
1052     int r;
1053     suppress_error = 0;
1054     r = guestfs_umount_all (g);
1055     if (r == -1)
1056       return -1;
1057   }
1058   {
1059     int r;
1060     suppress_error = 0;
1061     r = guestfs_lvm_remove_all (g);
1062     if (r == -1)
1063       return -1;
1064   }
1065   {
1066     char *lines[] = {
1067       ",",
1068       NULL
1069     };
1070     int r;
1071     suppress_error = 0;
1072     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1073     if (r == -1)
1074       return -1;
1075   }
1076   {
1077     int r;
1078     suppress_error = 0;
1079     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1080     if (r == -1)
1081       return -1;
1082   }
1083   {
1084     int r;
1085     suppress_error = 0;
1086     r = guestfs_mount (g, "/dev/sda1", "/");
1087     if (r == -1)
1088       return -1;
1089   }
1090   /* TestRun for set_e2uuid (3) */
1091   {
1092     int r;
1093     suppress_error = 0;
1094     r = guestfs_set_e2uuid (g, "/dev/sda1", "time");
1095     if (r == -1)
1096       return -1;
1097   }
1098   return 0;
1099 }
1100
1101 static int test_set_e2label_0 (void)
1102 {
1103   /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
1104   {
1105     int r;
1106     suppress_error = 0;
1107     r = guestfs_umount_all (g);
1108     if (r == -1)
1109       return -1;
1110   }
1111   {
1112     int r;
1113     suppress_error = 0;
1114     r = guestfs_lvm_remove_all (g);
1115     if (r == -1)
1116       return -1;
1117   }
1118   {
1119     char *lines[] = {
1120       ",",
1121       NULL
1122     };
1123     int r;
1124     suppress_error = 0;
1125     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1126     if (r == -1)
1127       return -1;
1128   }
1129   {
1130     int r;
1131     suppress_error = 0;
1132     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1133     if (r == -1)
1134       return -1;
1135   }
1136   {
1137     int r;
1138     suppress_error = 0;
1139     r = guestfs_mount (g, "/dev/sda1", "/");
1140     if (r == -1)
1141       return -1;
1142   }
1143   /* TestOutput for set_e2label (0) */
1144   {
1145     int r;
1146     suppress_error = 0;
1147     r = guestfs_set_e2label (g, "/dev/sda1", "testlabel");
1148     if (r == -1)
1149       return -1;
1150   }
1151   {
1152     char *r;
1153     suppress_error = 0;
1154     r = guestfs_get_e2label (g, "/dev/sda1");
1155     if (r == NULL)
1156       return -1;
1157     if (strcmp (r, "testlabel") != 0) {
1158       fprintf (stderr, "test_set_e2label_0: expected \"testlabel\" but got \"%s\"\n", r);
1159       return -1;
1160     }
1161     free (r);
1162   }
1163   return 0;
1164 }
1165
1166 static int test_pvremove_0 (void)
1167 {
1168   /* InitEmpty for pvremove (0) */
1169   {
1170     int r;
1171     suppress_error = 0;
1172     r = guestfs_umount_all (g);
1173     if (r == -1)
1174       return -1;
1175   }
1176   {
1177     int r;
1178     suppress_error = 0;
1179     r = guestfs_lvm_remove_all (g);
1180     if (r == -1)
1181       return -1;
1182   }
1183   /* TestOutputList for pvremove (0) */
1184   {
1185     int r;
1186     suppress_error = 0;
1187     r = guestfs_pvcreate (g, "/dev/sda");
1188     if (r == -1)
1189       return -1;
1190   }
1191   {
1192     char *physvols[] = {
1193       "/dev/sda",
1194       NULL
1195     };
1196     int r;
1197     suppress_error = 0;
1198     r = guestfs_vgcreate (g, "VG", physvols);
1199     if (r == -1)
1200       return -1;
1201   }
1202   {
1203     int r;
1204     suppress_error = 0;
1205     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1206     if (r == -1)
1207       return -1;
1208   }
1209   {
1210     int r;
1211     suppress_error = 0;
1212     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1213     if (r == -1)
1214       return -1;
1215   }
1216   {
1217     int r;
1218     suppress_error = 0;
1219     r = guestfs_vgremove (g, "VG");
1220     if (r == -1)
1221       return -1;
1222   }
1223   {
1224     int r;
1225     suppress_error = 0;
1226     r = guestfs_pvremove (g, "/dev/sda");
1227     if (r == -1)
1228       return -1;
1229   }
1230   {
1231     char **r;
1232     int i;
1233     suppress_error = 0;
1234     r = guestfs_lvs (g);
1235     if (r == NULL)
1236       return -1;
1237     if (r[0] != NULL) {
1238       fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
1239       print_strings (r);
1240       return -1;
1241     }
1242     for (i = 0; r[i] != NULL; ++i)
1243       free (r[i]);
1244     free (r);
1245   }
1246   return 0;
1247 }
1248
1249 static int test_pvremove_1 (void)
1250 {
1251   /* InitEmpty for pvremove (1) */
1252   {
1253     int r;
1254     suppress_error = 0;
1255     r = guestfs_umount_all (g);
1256     if (r == -1)
1257       return -1;
1258   }
1259   {
1260     int r;
1261     suppress_error = 0;
1262     r = guestfs_lvm_remove_all (g);
1263     if (r == -1)
1264       return -1;
1265   }
1266   /* TestOutputList for pvremove (1) */
1267   {
1268     int r;
1269     suppress_error = 0;
1270     r = guestfs_pvcreate (g, "/dev/sda");
1271     if (r == -1)
1272       return -1;
1273   }
1274   {
1275     char *physvols[] = {
1276       "/dev/sda",
1277       NULL
1278     };
1279     int r;
1280     suppress_error = 0;
1281     r = guestfs_vgcreate (g, "VG", physvols);
1282     if (r == -1)
1283       return -1;
1284   }
1285   {
1286     int r;
1287     suppress_error = 0;
1288     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1289     if (r == -1)
1290       return -1;
1291   }
1292   {
1293     int r;
1294     suppress_error = 0;
1295     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1296     if (r == -1)
1297       return -1;
1298   }
1299   {
1300     int r;
1301     suppress_error = 0;
1302     r = guestfs_vgremove (g, "VG");
1303     if (r == -1)
1304       return -1;
1305   }
1306   {
1307     int r;
1308     suppress_error = 0;
1309     r = guestfs_pvremove (g, "/dev/sda");
1310     if (r == -1)
1311       return -1;
1312   }
1313   {
1314     char **r;
1315     int i;
1316     suppress_error = 0;
1317     r = guestfs_vgs (g);
1318     if (r == NULL)
1319       return -1;
1320     if (r[0] != NULL) {
1321       fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
1322       print_strings (r);
1323       return -1;
1324     }
1325     for (i = 0; r[i] != NULL; ++i)
1326       free (r[i]);
1327     free (r);
1328   }
1329   return 0;
1330 }
1331
1332 static int test_pvremove_2 (void)
1333 {
1334   /* InitEmpty for pvremove (2) */
1335   {
1336     int r;
1337     suppress_error = 0;
1338     r = guestfs_umount_all (g);
1339     if (r == -1)
1340       return -1;
1341   }
1342   {
1343     int r;
1344     suppress_error = 0;
1345     r = guestfs_lvm_remove_all (g);
1346     if (r == -1)
1347       return -1;
1348   }
1349   /* TestOutputList for pvremove (2) */
1350   {
1351     int r;
1352     suppress_error = 0;
1353     r = guestfs_pvcreate (g, "/dev/sda");
1354     if (r == -1)
1355       return -1;
1356   }
1357   {
1358     char *physvols[] = {
1359       "/dev/sda",
1360       NULL
1361     };
1362     int r;
1363     suppress_error = 0;
1364     r = guestfs_vgcreate (g, "VG", physvols);
1365     if (r == -1)
1366       return -1;
1367   }
1368   {
1369     int r;
1370     suppress_error = 0;
1371     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1372     if (r == -1)
1373       return -1;
1374   }
1375   {
1376     int r;
1377     suppress_error = 0;
1378     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1379     if (r == -1)
1380       return -1;
1381   }
1382   {
1383     int r;
1384     suppress_error = 0;
1385     r = guestfs_vgremove (g, "VG");
1386     if (r == -1)
1387       return -1;
1388   }
1389   {
1390     int r;
1391     suppress_error = 0;
1392     r = guestfs_pvremove (g, "/dev/sda");
1393     if (r == -1)
1394       return -1;
1395   }
1396   {
1397     char **r;
1398     int i;
1399     suppress_error = 0;
1400     r = guestfs_pvs (g);
1401     if (r == NULL)
1402       return -1;
1403     if (r[0] != NULL) {
1404       fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
1405       print_strings (r);
1406       return -1;
1407     }
1408     for (i = 0; r[i] != NULL; ++i)
1409       free (r[i]);
1410     free (r);
1411   }
1412   return 0;
1413 }
1414
1415 static int test_vgremove_0 (void)
1416 {
1417   /* InitEmpty for vgremove (0) */
1418   {
1419     int r;
1420     suppress_error = 0;
1421     r = guestfs_umount_all (g);
1422     if (r == -1)
1423       return -1;
1424   }
1425   {
1426     int r;
1427     suppress_error = 0;
1428     r = guestfs_lvm_remove_all (g);
1429     if (r == -1)
1430       return -1;
1431   }
1432   /* TestOutputList for vgremove (0) */
1433   {
1434     int r;
1435     suppress_error = 0;
1436     r = guestfs_pvcreate (g, "/dev/sda");
1437     if (r == -1)
1438       return -1;
1439   }
1440   {
1441     char *physvols[] = {
1442       "/dev/sda",
1443       NULL
1444     };
1445     int r;
1446     suppress_error = 0;
1447     r = guestfs_vgcreate (g, "VG", physvols);
1448     if (r == -1)
1449       return -1;
1450   }
1451   {
1452     int r;
1453     suppress_error = 0;
1454     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1455     if (r == -1)
1456       return -1;
1457   }
1458   {
1459     int r;
1460     suppress_error = 0;
1461     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1462     if (r == -1)
1463       return -1;
1464   }
1465   {
1466     int r;
1467     suppress_error = 0;
1468     r = guestfs_vgremove (g, "VG");
1469     if (r == -1)
1470       return -1;
1471   }
1472   {
1473     char **r;
1474     int i;
1475     suppress_error = 0;
1476     r = guestfs_lvs (g);
1477     if (r == NULL)
1478       return -1;
1479     if (r[0] != NULL) {
1480       fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
1481       print_strings (r);
1482       return -1;
1483     }
1484     for (i = 0; r[i] != NULL; ++i)
1485       free (r[i]);
1486     free (r);
1487   }
1488   return 0;
1489 }
1490
1491 static int test_vgremove_1 (void)
1492 {
1493   /* InitEmpty for vgremove (1) */
1494   {
1495     int r;
1496     suppress_error = 0;
1497     r = guestfs_umount_all (g);
1498     if (r == -1)
1499       return -1;
1500   }
1501   {
1502     int r;
1503     suppress_error = 0;
1504     r = guestfs_lvm_remove_all (g);
1505     if (r == -1)
1506       return -1;
1507   }
1508   /* TestOutputList for vgremove (1) */
1509   {
1510     int r;
1511     suppress_error = 0;
1512     r = guestfs_pvcreate (g, "/dev/sda");
1513     if (r == -1)
1514       return -1;
1515   }
1516   {
1517     char *physvols[] = {
1518       "/dev/sda",
1519       NULL
1520     };
1521     int r;
1522     suppress_error = 0;
1523     r = guestfs_vgcreate (g, "VG", physvols);
1524     if (r == -1)
1525       return -1;
1526   }
1527   {
1528     int r;
1529     suppress_error = 0;
1530     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1531     if (r == -1)
1532       return -1;
1533   }
1534   {
1535     int r;
1536     suppress_error = 0;
1537     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1538     if (r == -1)
1539       return -1;
1540   }
1541   {
1542     int r;
1543     suppress_error = 0;
1544     r = guestfs_vgremove (g, "VG");
1545     if (r == -1)
1546       return -1;
1547   }
1548   {
1549     char **r;
1550     int i;
1551     suppress_error = 0;
1552     r = guestfs_vgs (g);
1553     if (r == NULL)
1554       return -1;
1555     if (r[0] != NULL) {
1556       fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
1557       print_strings (r);
1558       return -1;
1559     }
1560     for (i = 0; r[i] != NULL; ++i)
1561       free (r[i]);
1562     free (r);
1563   }
1564   return 0;
1565 }
1566
1567 static int test_lvremove_0 (void)
1568 {
1569   /* InitEmpty for lvremove (0) */
1570   {
1571     int r;
1572     suppress_error = 0;
1573     r = guestfs_umount_all (g);
1574     if (r == -1)
1575       return -1;
1576   }
1577   {
1578     int r;
1579     suppress_error = 0;
1580     r = guestfs_lvm_remove_all (g);
1581     if (r == -1)
1582       return -1;
1583   }
1584   /* TestOutputList for lvremove (0) */
1585   {
1586     int r;
1587     suppress_error = 0;
1588     r = guestfs_pvcreate (g, "/dev/sda");
1589     if (r == -1)
1590       return -1;
1591   }
1592   {
1593     char *physvols[] = {
1594       "/dev/sda",
1595       NULL
1596     };
1597     int r;
1598     suppress_error = 0;
1599     r = guestfs_vgcreate (g, "VG", physvols);
1600     if (r == -1)
1601       return -1;
1602   }
1603   {
1604     int r;
1605     suppress_error = 0;
1606     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1607     if (r == -1)
1608       return -1;
1609   }
1610   {
1611     int r;
1612     suppress_error = 0;
1613     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1614     if (r == -1)
1615       return -1;
1616   }
1617   {
1618     int r;
1619     suppress_error = 0;
1620     r = guestfs_lvremove (g, "/dev/VG/LV1");
1621     if (r == -1)
1622       return -1;
1623   }
1624   {
1625     char **r;
1626     int i;
1627     suppress_error = 0;
1628     r = guestfs_lvs (g);
1629     if (r == NULL)
1630       return -1;
1631     if (!r[0]) {
1632       fprintf (stderr, "test_lvremove_0: short list returned from command\n");
1633       print_strings (r);
1634       return -1;
1635     }
1636     if (strcmp (r[0], "/dev/VG/LV2") != 0) {
1637       fprintf (stderr, "test_lvremove_0: expected \"/dev/VG/LV2\" but got \"%s\"\n", r[0]);
1638       return -1;
1639     }
1640     if (r[1] != NULL) {
1641       fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
1642       print_strings (r);
1643       return -1;
1644     }
1645     for (i = 0; r[i] != NULL; ++i)
1646       free (r[i]);
1647     free (r);
1648   }
1649   return 0;
1650 }
1651
1652 static int test_lvremove_1 (void)
1653 {
1654   /* InitEmpty for lvremove (1) */
1655   {
1656     int r;
1657     suppress_error = 0;
1658     r = guestfs_umount_all (g);
1659     if (r == -1)
1660       return -1;
1661   }
1662   {
1663     int r;
1664     suppress_error = 0;
1665     r = guestfs_lvm_remove_all (g);
1666     if (r == -1)
1667       return -1;
1668   }
1669   /* TestOutputList for lvremove (1) */
1670   {
1671     int r;
1672     suppress_error = 0;
1673     r = guestfs_pvcreate (g, "/dev/sda");
1674     if (r == -1)
1675       return -1;
1676   }
1677   {
1678     char *physvols[] = {
1679       "/dev/sda",
1680       NULL
1681     };
1682     int r;
1683     suppress_error = 0;
1684     r = guestfs_vgcreate (g, "VG", physvols);
1685     if (r == -1)
1686       return -1;
1687   }
1688   {
1689     int r;
1690     suppress_error = 0;
1691     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1692     if (r == -1)
1693       return -1;
1694   }
1695   {
1696     int r;
1697     suppress_error = 0;
1698     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1699     if (r == -1)
1700       return -1;
1701   }
1702   {
1703     int r;
1704     suppress_error = 0;
1705     r = guestfs_lvremove (g, "/dev/VG");
1706     if (r == -1)
1707       return -1;
1708   }
1709   {
1710     char **r;
1711     int i;
1712     suppress_error = 0;
1713     r = guestfs_lvs (g);
1714     if (r == NULL)
1715       return -1;
1716     if (r[0] != NULL) {
1717       fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
1718       print_strings (r);
1719       return -1;
1720     }
1721     for (i = 0; r[i] != NULL; ++i)
1722       free (r[i]);
1723     free (r);
1724   }
1725   return 0;
1726 }
1727
1728 static int test_lvremove_2 (void)
1729 {
1730   /* InitEmpty for lvremove (2) */
1731   {
1732     int r;
1733     suppress_error = 0;
1734     r = guestfs_umount_all (g);
1735     if (r == -1)
1736       return -1;
1737   }
1738   {
1739     int r;
1740     suppress_error = 0;
1741     r = guestfs_lvm_remove_all (g);
1742     if (r == -1)
1743       return -1;
1744   }
1745   /* TestOutputList for lvremove (2) */
1746   {
1747     int r;
1748     suppress_error = 0;
1749     r = guestfs_pvcreate (g, "/dev/sda");
1750     if (r == -1)
1751       return -1;
1752   }
1753   {
1754     char *physvols[] = {
1755       "/dev/sda",
1756       NULL
1757     };
1758     int r;
1759     suppress_error = 0;
1760     r = guestfs_vgcreate (g, "VG", physvols);
1761     if (r == -1)
1762       return -1;
1763   }
1764   {
1765     int r;
1766     suppress_error = 0;
1767     r = guestfs_lvcreate (g, "LV1", "VG", 50);
1768     if (r == -1)
1769       return -1;
1770   }
1771   {
1772     int r;
1773     suppress_error = 0;
1774     r = guestfs_lvcreate (g, "LV2", "VG", 50);
1775     if (r == -1)
1776       return -1;
1777   }
1778   {
1779     int r;
1780     suppress_error = 0;
1781     r = guestfs_lvremove (g, "/dev/VG");
1782     if (r == -1)
1783       return -1;
1784   }
1785   {
1786     char **r;
1787     int i;
1788     suppress_error = 0;
1789     r = guestfs_vgs (g);
1790     if (r == NULL)
1791       return -1;
1792     if (!r[0]) {
1793       fprintf (stderr, "test_lvremove_2: short list returned from command\n");
1794       print_strings (r);
1795       return -1;
1796     }
1797     if (strcmp (r[0], "VG") != 0) {
1798       fprintf (stderr, "test_lvremove_2: expected \"VG\" but got \"%s\"\n", r[0]);
1799       return -1;
1800     }
1801     if (r[1] != NULL) {
1802       fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
1803       print_strings (r);
1804       return -1;
1805     }
1806     for (i = 0; r[i] != NULL; ++i)
1807       free (r[i]);
1808     free (r);
1809   }
1810   return 0;
1811 }
1812
1813 static int test_mount_ro_0 (void)
1814 {
1815   /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
1816   {
1817     int r;
1818     suppress_error = 0;
1819     r = guestfs_umount_all (g);
1820     if (r == -1)
1821       return -1;
1822   }
1823   {
1824     int r;
1825     suppress_error = 0;
1826     r = guestfs_lvm_remove_all (g);
1827     if (r == -1)
1828       return -1;
1829   }
1830   {
1831     char *lines[] = {
1832       ",",
1833       NULL
1834     };
1835     int r;
1836     suppress_error = 0;
1837     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1838     if (r == -1)
1839       return -1;
1840   }
1841   {
1842     int r;
1843     suppress_error = 0;
1844     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1845     if (r == -1)
1846       return -1;
1847   }
1848   {
1849     int r;
1850     suppress_error = 0;
1851     r = guestfs_mount (g, "/dev/sda1", "/");
1852     if (r == -1)
1853       return -1;
1854   }
1855   /* TestLastFail for mount_ro (0) */
1856   {
1857     int r;
1858     suppress_error = 0;
1859     r = guestfs_umount (g, "/");
1860     if (r == -1)
1861       return -1;
1862   }
1863   {
1864     int r;
1865     suppress_error = 0;
1866     r = guestfs_mount_ro (g, "/dev/sda1", "/");
1867     if (r == -1)
1868       return -1;
1869   }
1870   {
1871     int r;
1872     suppress_error = 1;
1873     r = guestfs_touch (g, "/new");
1874     if (r != -1)
1875       return -1;
1876   }
1877   return 0;
1878 }
1879
1880 static int test_mount_ro_1 (void)
1881 {
1882   /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
1883   {
1884     int r;
1885     suppress_error = 0;
1886     r = guestfs_umount_all (g);
1887     if (r == -1)
1888       return -1;
1889   }
1890   {
1891     int r;
1892     suppress_error = 0;
1893     r = guestfs_lvm_remove_all (g);
1894     if (r == -1)
1895       return -1;
1896   }
1897   {
1898     char *lines[] = {
1899       ",",
1900       NULL
1901     };
1902     int r;
1903     suppress_error = 0;
1904     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1905     if (r == -1)
1906       return -1;
1907   }
1908   {
1909     int r;
1910     suppress_error = 0;
1911     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1912     if (r == -1)
1913       return -1;
1914   }
1915   {
1916     int r;
1917     suppress_error = 0;
1918     r = guestfs_mount (g, "/dev/sda1", "/");
1919     if (r == -1)
1920       return -1;
1921   }
1922   /* TestOutput for mount_ro (1) */
1923   {
1924     int r;
1925     suppress_error = 0;
1926     r = guestfs_write_file (g, "/new", "data", 0);
1927     if (r == -1)
1928       return -1;
1929   }
1930   {
1931     int r;
1932     suppress_error = 0;
1933     r = guestfs_umount (g, "/");
1934     if (r == -1)
1935       return -1;
1936   }
1937   {
1938     int r;
1939     suppress_error = 0;
1940     r = guestfs_mount_ro (g, "/dev/sda1", "/");
1941     if (r == -1)
1942       return -1;
1943   }
1944   {
1945     char *r;
1946     suppress_error = 0;
1947     r = guestfs_cat (g, "/new");
1948     if (r == NULL)
1949       return -1;
1950     if (strcmp (r, "data") != 0) {
1951       fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
1952       return -1;
1953     }
1954     free (r);
1955   }
1956   return 0;
1957 }
1958
1959 static int test_tgz_in_0 (void)
1960 {
1961   /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
1962   {
1963     int r;
1964     suppress_error = 0;
1965     r = guestfs_umount_all (g);
1966     if (r == -1)
1967       return -1;
1968   }
1969   {
1970     int r;
1971     suppress_error = 0;
1972     r = guestfs_lvm_remove_all (g);
1973     if (r == -1)
1974       return -1;
1975   }
1976   {
1977     char *lines[] = {
1978       ",",
1979       NULL
1980     };
1981     int r;
1982     suppress_error = 0;
1983     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1984     if (r == -1)
1985       return -1;
1986   }
1987   {
1988     int r;
1989     suppress_error = 0;
1990     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1991     if (r == -1)
1992       return -1;
1993   }
1994   {
1995     int r;
1996     suppress_error = 0;
1997     r = guestfs_mount (g, "/dev/sda1", "/");
1998     if (r == -1)
1999       return -1;
2000   }
2001   /* TestOutput for tgz_in (0) */
2002   {
2003     int r;
2004     suppress_error = 0;
2005     r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
2006     if (r == -1)
2007       return -1;
2008   }
2009   {
2010     char *r;
2011     suppress_error = 0;
2012     r = guestfs_cat (g, "/hello");
2013     if (r == NULL)
2014       return -1;
2015     if (strcmp (r, "hello\n") != 0) {
2016       fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
2017       return -1;
2018     }
2019     free (r);
2020   }
2021   return 0;
2022 }
2023
2024 static int test_tar_in_0 (void)
2025 {
2026   /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
2027   {
2028     int r;
2029     suppress_error = 0;
2030     r = guestfs_umount_all (g);
2031     if (r == -1)
2032       return -1;
2033   }
2034   {
2035     int r;
2036     suppress_error = 0;
2037     r = guestfs_lvm_remove_all (g);
2038     if (r == -1)
2039       return -1;
2040   }
2041   {
2042     char *lines[] = {
2043       ",",
2044       NULL
2045     };
2046     int r;
2047     suppress_error = 0;
2048     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2049     if (r == -1)
2050       return -1;
2051   }
2052   {
2053     int r;
2054     suppress_error = 0;
2055     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2056     if (r == -1)
2057       return -1;
2058   }
2059   {
2060     int r;
2061     suppress_error = 0;
2062     r = guestfs_mount (g, "/dev/sda1", "/");
2063     if (r == -1)
2064       return -1;
2065   }
2066   /* TestOutput for tar_in (0) */
2067   {
2068     int r;
2069     suppress_error = 0;
2070     r = guestfs_tar_in (g, "images/helloworld.tar", "/");
2071     if (r == -1)
2072       return -1;
2073   }
2074   {
2075     char *r;
2076     suppress_error = 0;
2077     r = guestfs_cat (g, "/hello");
2078     if (r == NULL)
2079       return -1;
2080     if (strcmp (r, "hello\n") != 0) {
2081       fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
2082       return -1;
2083     }
2084     free (r);
2085   }
2086   return 0;
2087 }
2088
2089 static int test_checksum_0 (void)
2090 {
2091   /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
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   {
2107     char *lines[] = {
2108       ",",
2109       NULL
2110     };
2111     int r;
2112     suppress_error = 0;
2113     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2114     if (r == -1)
2115       return -1;
2116   }
2117   {
2118     int r;
2119     suppress_error = 0;
2120     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2121     if (r == -1)
2122       return -1;
2123   }
2124   {
2125     int r;
2126     suppress_error = 0;
2127     r = guestfs_mount (g, "/dev/sda1", "/");
2128     if (r == -1)
2129       return -1;
2130   }
2131   /* TestOutput for checksum (0) */
2132   {
2133     int r;
2134     suppress_error = 0;
2135     r = guestfs_write_file (g, "/new", "test\n", 0);
2136     if (r == -1)
2137       return -1;
2138   }
2139   {
2140     char *r;
2141     suppress_error = 0;
2142     r = guestfs_checksum (g, "crc", "/new");
2143     if (r == NULL)
2144       return -1;
2145     if (strcmp (r, "935282863") != 0) {
2146       fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
2147       return -1;
2148     }
2149     free (r);
2150   }
2151   return 0;
2152 }
2153
2154 static int test_checksum_1 (void)
2155 {
2156   /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
2157   {
2158     int r;
2159     suppress_error = 0;
2160     r = guestfs_umount_all (g);
2161     if (r == -1)
2162       return -1;
2163   }
2164   {
2165     int r;
2166     suppress_error = 0;
2167     r = guestfs_lvm_remove_all (g);
2168     if (r == -1)
2169       return -1;
2170   }
2171   {
2172     char *lines[] = {
2173       ",",
2174       NULL
2175     };
2176     int r;
2177     suppress_error = 0;
2178     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2179     if (r == -1)
2180       return -1;
2181   }
2182   {
2183     int r;
2184     suppress_error = 0;
2185     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2186     if (r == -1)
2187       return -1;
2188   }
2189   {
2190     int r;
2191     suppress_error = 0;
2192     r = guestfs_mount (g, "/dev/sda1", "/");
2193     if (r == -1)
2194       return -1;
2195   }
2196   /* TestLastFail for checksum (1) */
2197   {
2198     char *r;
2199     suppress_error = 1;
2200     r = guestfs_checksum (g, "crc", "/new");
2201     if (r != NULL)
2202       return -1;
2203     free (r);
2204   }
2205   return 0;
2206 }
2207
2208 static int test_checksum_2 (void)
2209 {
2210   /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
2211   {
2212     int r;
2213     suppress_error = 0;
2214     r = guestfs_umount_all (g);
2215     if (r == -1)
2216       return -1;
2217   }
2218   {
2219     int r;
2220     suppress_error = 0;
2221     r = guestfs_lvm_remove_all (g);
2222     if (r == -1)
2223       return -1;
2224   }
2225   {
2226     char *lines[] = {
2227       ",",
2228       NULL
2229     };
2230     int r;
2231     suppress_error = 0;
2232     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2233     if (r == -1)
2234       return -1;
2235   }
2236   {
2237     int r;
2238     suppress_error = 0;
2239     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2240     if (r == -1)
2241       return -1;
2242   }
2243   {
2244     int r;
2245     suppress_error = 0;
2246     r = guestfs_mount (g, "/dev/sda1", "/");
2247     if (r == -1)
2248       return -1;
2249   }
2250   /* TestOutput for checksum (2) */
2251   {
2252     int r;
2253     suppress_error = 0;
2254     r = guestfs_write_file (g, "/new", "test\n", 0);
2255     if (r == -1)
2256       return -1;
2257   }
2258   {
2259     char *r;
2260     suppress_error = 0;
2261     r = guestfs_checksum (g, "md5", "/new");
2262     if (r == NULL)
2263       return -1;
2264     if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
2265       fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
2266       return -1;
2267     }
2268     free (r);
2269   }
2270   return 0;
2271 }
2272
2273 static int test_checksum_3 (void)
2274 {
2275   /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
2276   {
2277     int r;
2278     suppress_error = 0;
2279     r = guestfs_umount_all (g);
2280     if (r == -1)
2281       return -1;
2282   }
2283   {
2284     int r;
2285     suppress_error = 0;
2286     r = guestfs_lvm_remove_all (g);
2287     if (r == -1)
2288       return -1;
2289   }
2290   {
2291     char *lines[] = {
2292       ",",
2293       NULL
2294     };
2295     int r;
2296     suppress_error = 0;
2297     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2298     if (r == -1)
2299       return -1;
2300   }
2301   {
2302     int r;
2303     suppress_error = 0;
2304     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2305     if (r == -1)
2306       return -1;
2307   }
2308   {
2309     int r;
2310     suppress_error = 0;
2311     r = guestfs_mount (g, "/dev/sda1", "/");
2312     if (r == -1)
2313       return -1;
2314   }
2315   /* TestOutput for checksum (3) */
2316   {
2317     int r;
2318     suppress_error = 0;
2319     r = guestfs_write_file (g, "/new", "test\n", 0);
2320     if (r == -1)
2321       return -1;
2322   }
2323   {
2324     char *r;
2325     suppress_error = 0;
2326     r = guestfs_checksum (g, "sha1", "/new");
2327     if (r == NULL)
2328       return -1;
2329     if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
2330       fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
2331       return -1;
2332     }
2333     free (r);
2334   }
2335   return 0;
2336 }
2337
2338 static int test_checksum_4 (void)
2339 {
2340   /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
2341   {
2342     int r;
2343     suppress_error = 0;
2344     r = guestfs_umount_all (g);
2345     if (r == -1)
2346       return -1;
2347   }
2348   {
2349     int r;
2350     suppress_error = 0;
2351     r = guestfs_lvm_remove_all (g);
2352     if (r == -1)
2353       return -1;
2354   }
2355   {
2356     char *lines[] = {
2357       ",",
2358       NULL
2359     };
2360     int r;
2361     suppress_error = 0;
2362     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2363     if (r == -1)
2364       return -1;
2365   }
2366   {
2367     int r;
2368     suppress_error = 0;
2369     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2370     if (r == -1)
2371       return -1;
2372   }
2373   {
2374     int r;
2375     suppress_error = 0;
2376     r = guestfs_mount (g, "/dev/sda1", "/");
2377     if (r == -1)
2378       return -1;
2379   }
2380   /* TestOutput for checksum (4) */
2381   {
2382     int r;
2383     suppress_error = 0;
2384     r = guestfs_write_file (g, "/new", "test\n", 0);
2385     if (r == -1)
2386       return -1;
2387   }
2388   {
2389     char *r;
2390     suppress_error = 0;
2391     r = guestfs_checksum (g, "sha224", "/new");
2392     if (r == NULL)
2393       return -1;
2394     if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
2395       fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
2396       return -1;
2397     }
2398     free (r);
2399   }
2400   return 0;
2401 }
2402
2403 static int test_checksum_5 (void)
2404 {
2405   /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
2406   {
2407     int r;
2408     suppress_error = 0;
2409     r = guestfs_umount_all (g);
2410     if (r == -1)
2411       return -1;
2412   }
2413   {
2414     int r;
2415     suppress_error = 0;
2416     r = guestfs_lvm_remove_all (g);
2417     if (r == -1)
2418       return -1;
2419   }
2420   {
2421     char *lines[] = {
2422       ",",
2423       NULL
2424     };
2425     int r;
2426     suppress_error = 0;
2427     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2428     if (r == -1)
2429       return -1;
2430   }
2431   {
2432     int r;
2433     suppress_error = 0;
2434     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2435     if (r == -1)
2436       return -1;
2437   }
2438   {
2439     int r;
2440     suppress_error = 0;
2441     r = guestfs_mount (g, "/dev/sda1", "/");
2442     if (r == -1)
2443       return -1;
2444   }
2445   /* TestOutput for checksum (5) */
2446   {
2447     int r;
2448     suppress_error = 0;
2449     r = guestfs_write_file (g, "/new", "test\n", 0);
2450     if (r == -1)
2451       return -1;
2452   }
2453   {
2454     char *r;
2455     suppress_error = 0;
2456     r = guestfs_checksum (g, "sha256", "/new");
2457     if (r == NULL)
2458       return -1;
2459     if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
2460       fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
2461       return -1;
2462     }
2463     free (r);
2464   }
2465   return 0;
2466 }
2467
2468 static int test_checksum_6 (void)
2469 {
2470   /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
2471   {
2472     int r;
2473     suppress_error = 0;
2474     r = guestfs_umount_all (g);
2475     if (r == -1)
2476       return -1;
2477   }
2478   {
2479     int r;
2480     suppress_error = 0;
2481     r = guestfs_lvm_remove_all (g);
2482     if (r == -1)
2483       return -1;
2484   }
2485   {
2486     char *lines[] = {
2487       ",",
2488       NULL
2489     };
2490     int r;
2491     suppress_error = 0;
2492     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2493     if (r == -1)
2494       return -1;
2495   }
2496   {
2497     int r;
2498     suppress_error = 0;
2499     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2500     if (r == -1)
2501       return -1;
2502   }
2503   {
2504     int r;
2505     suppress_error = 0;
2506     r = guestfs_mount (g, "/dev/sda1", "/");
2507     if (r == -1)
2508       return -1;
2509   }
2510   /* TestOutput for checksum (6) */
2511   {
2512     int r;
2513     suppress_error = 0;
2514     r = guestfs_write_file (g, "/new", "test\n", 0);
2515     if (r == -1)
2516       return -1;
2517   }
2518   {
2519     char *r;
2520     suppress_error = 0;
2521     r = guestfs_checksum (g, "sha384", "/new");
2522     if (r == NULL)
2523       return -1;
2524     if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
2525       fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
2526       return -1;
2527     }
2528     free (r);
2529   }
2530   return 0;
2531 }
2532
2533 static int test_checksum_7 (void)
2534 {
2535   /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
2536   {
2537     int r;
2538     suppress_error = 0;
2539     r = guestfs_umount_all (g);
2540     if (r == -1)
2541       return -1;
2542   }
2543   {
2544     int r;
2545     suppress_error = 0;
2546     r = guestfs_lvm_remove_all (g);
2547     if (r == -1)
2548       return -1;
2549   }
2550   {
2551     char *lines[] = {
2552       ",",
2553       NULL
2554     };
2555     int r;
2556     suppress_error = 0;
2557     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2558     if (r == -1)
2559       return -1;
2560   }
2561   {
2562     int r;
2563     suppress_error = 0;
2564     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2565     if (r == -1)
2566       return -1;
2567   }
2568   {
2569     int r;
2570     suppress_error = 0;
2571     r = guestfs_mount (g, "/dev/sda1", "/");
2572     if (r == -1)
2573       return -1;
2574   }
2575   /* TestOutput for checksum (7) */
2576   {
2577     int r;
2578     suppress_error = 0;
2579     r = guestfs_write_file (g, "/new", "test\n", 0);
2580     if (r == -1)
2581       return -1;
2582   }
2583   {
2584     char *r;
2585     suppress_error = 0;
2586     r = guestfs_checksum (g, "sha512", "/new");
2587     if (r == NULL)
2588       return -1;
2589     if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
2590       fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
2591       return -1;
2592     }
2593     free (r);
2594   }
2595   return 0;
2596 }
2597
2598 static int test_download_0 (void)
2599 {
2600   /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
2601   {
2602     int r;
2603     suppress_error = 0;
2604     r = guestfs_umount_all (g);
2605     if (r == -1)
2606       return -1;
2607   }
2608   {
2609     int r;
2610     suppress_error = 0;
2611     r = guestfs_lvm_remove_all (g);
2612     if (r == -1)
2613       return -1;
2614   }
2615   {
2616     char *lines[] = {
2617       ",",
2618       NULL
2619     };
2620     int r;
2621     suppress_error = 0;
2622     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2623     if (r == -1)
2624       return -1;
2625   }
2626   {
2627     int r;
2628     suppress_error = 0;
2629     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2630     if (r == -1)
2631       return -1;
2632   }
2633   {
2634     int r;
2635     suppress_error = 0;
2636     r = guestfs_mount (g, "/dev/sda1", "/");
2637     if (r == -1)
2638       return -1;
2639   }
2640   /* TestOutput for download (0) */
2641   {
2642     int r;
2643     suppress_error = 0;
2644     r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2645     if (r == -1)
2646       return -1;
2647   }
2648   {
2649     int r;
2650     suppress_error = 0;
2651     r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
2652     if (r == -1)
2653       return -1;
2654   }
2655   {
2656     int r;
2657     suppress_error = 0;
2658     r = guestfs_upload (g, "testdownload.tmp", "/upload");
2659     if (r == -1)
2660       return -1;
2661   }
2662   {
2663     char *r;
2664     suppress_error = 0;
2665     r = guestfs_checksum (g, "md5", "/upload");
2666     if (r == NULL)
2667       return -1;
2668     if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2669       fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2670       return -1;
2671     }
2672     free (r);
2673   }
2674   return 0;
2675 }
2676
2677 static int test_upload_0 (void)
2678 {
2679   /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
2680   {
2681     int r;
2682     suppress_error = 0;
2683     r = guestfs_umount_all (g);
2684     if (r == -1)
2685       return -1;
2686   }
2687   {
2688     int r;
2689     suppress_error = 0;
2690     r = guestfs_lvm_remove_all (g);
2691     if (r == -1)
2692       return -1;
2693   }
2694   {
2695     char *lines[] = {
2696       ",",
2697       NULL
2698     };
2699     int r;
2700     suppress_error = 0;
2701     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2702     if (r == -1)
2703       return -1;
2704   }
2705   {
2706     int r;
2707     suppress_error = 0;
2708     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2709     if (r == -1)
2710       return -1;
2711   }
2712   {
2713     int r;
2714     suppress_error = 0;
2715     r = guestfs_mount (g, "/dev/sda1", "/");
2716     if (r == -1)
2717       return -1;
2718   }
2719   /* TestOutput for upload (0) */
2720   {
2721     int r;
2722     suppress_error = 0;
2723     r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2724     if (r == -1)
2725       return -1;
2726   }
2727   {
2728     char *r;
2729     suppress_error = 0;
2730     r = guestfs_checksum (g, "md5", "/COPYING.LIB");
2731     if (r == NULL)
2732       return -1;
2733     if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2734       fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2735       return -1;
2736     }
2737     free (r);
2738   }
2739   return 0;
2740 }
2741
2742 static int test_blockdev_rereadpt_0 (void)
2743 {
2744   /* InitEmpty for blockdev_rereadpt (0) */
2745   {
2746     int r;
2747     suppress_error = 0;
2748     r = guestfs_umount_all (g);
2749     if (r == -1)
2750       return -1;
2751   }
2752   {
2753     int r;
2754     suppress_error = 0;
2755     r = guestfs_lvm_remove_all (g);
2756     if (r == -1)
2757       return -1;
2758   }
2759   /* TestRun for blockdev_rereadpt (0) */
2760   {
2761     int r;
2762     suppress_error = 0;
2763     r = guestfs_blockdev_rereadpt (g, "/dev/sda");
2764     if (r == -1)
2765       return -1;
2766   }
2767   return 0;
2768 }
2769
2770 static int test_blockdev_flushbufs_0 (void)
2771 {
2772   /* InitEmpty for blockdev_flushbufs (0) */
2773   {
2774     int r;
2775     suppress_error = 0;
2776     r = guestfs_umount_all (g);
2777     if (r == -1)
2778       return -1;
2779   }
2780   {
2781     int r;
2782     suppress_error = 0;
2783     r = guestfs_lvm_remove_all (g);
2784     if (r == -1)
2785       return -1;
2786   }
2787   /* TestRun for blockdev_flushbufs (0) */
2788   {
2789     int r;
2790     suppress_error = 0;
2791     r = guestfs_blockdev_flushbufs (g, "/dev/sda");
2792     if (r == -1)
2793       return -1;
2794   }
2795   return 0;
2796 }
2797
2798 static int test_blockdev_getsize64_0 (void)
2799 {
2800   /* InitEmpty for blockdev_getsize64 (0) */
2801   {
2802     int r;
2803     suppress_error = 0;
2804     r = guestfs_umount_all (g);
2805     if (r == -1)
2806       return -1;
2807   }
2808   {
2809     int r;
2810     suppress_error = 0;
2811     r = guestfs_lvm_remove_all (g);
2812     if (r == -1)
2813       return -1;
2814   }
2815   /* TestOutputInt for blockdev_getsize64 (0) */
2816   {
2817     int64_t r;
2818     suppress_error = 0;
2819     r = guestfs_blockdev_getsize64 (g, "/dev/sda");
2820     if (r == -1)
2821       return -1;
2822     if (r != 524288000) {
2823       fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n",               (int) r);
2824       return -1;
2825     }
2826   }
2827   return 0;
2828 }
2829
2830 static int test_blockdev_getsz_0 (void)
2831 {
2832   /* InitEmpty for blockdev_getsz (0) */
2833   {
2834     int r;
2835     suppress_error = 0;
2836     r = guestfs_umount_all (g);
2837     if (r == -1)
2838       return -1;
2839   }
2840   {
2841     int r;
2842     suppress_error = 0;
2843     r = guestfs_lvm_remove_all (g);
2844     if (r == -1)
2845       return -1;
2846   }
2847   /* TestOutputInt for blockdev_getsz (0) */
2848   {
2849     int64_t r;
2850     suppress_error = 0;
2851     r = guestfs_blockdev_getsz (g, "/dev/sda");
2852     if (r == -1)
2853       return -1;
2854     if (r != 1024000) {
2855       fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n",               (int) r);
2856       return -1;
2857     }
2858   }
2859   return 0;
2860 }
2861
2862 static int test_blockdev_getbsz_0 (void)
2863 {
2864   /* InitEmpty for blockdev_getbsz (0) */
2865   {
2866     int r;
2867     suppress_error = 0;
2868     r = guestfs_umount_all (g);
2869     if (r == -1)
2870       return -1;
2871   }
2872   {
2873     int r;
2874     suppress_error = 0;
2875     r = guestfs_lvm_remove_all (g);
2876     if (r == -1)
2877       return -1;
2878   }
2879   /* TestOutputInt for blockdev_getbsz (0) */
2880   {
2881     int r;
2882     suppress_error = 0;
2883     r = guestfs_blockdev_getbsz (g, "/dev/sda");
2884     if (r == -1)
2885       return -1;
2886     if (r != 4096) {
2887       fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n",               (int) r);
2888       return -1;
2889     }
2890   }
2891   return 0;
2892 }
2893
2894 static int test_blockdev_getss_0 (void)
2895 {
2896   /* InitEmpty for blockdev_getss (0) */
2897   {
2898     int r;
2899     suppress_error = 0;
2900     r = guestfs_umount_all (g);
2901     if (r == -1)
2902       return -1;
2903   }
2904   {
2905     int r;
2906     suppress_error = 0;
2907     r = guestfs_lvm_remove_all (g);
2908     if (r == -1)
2909       return -1;
2910   }
2911   /* TestOutputInt for blockdev_getss (0) */
2912   {
2913     int r;
2914     suppress_error = 0;
2915     r = guestfs_blockdev_getss (g, "/dev/sda");
2916     if (r == -1)
2917       return -1;
2918     if (r != 512) {
2919       fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n",               (int) r);
2920       return -1;
2921     }
2922   }
2923   return 0;
2924 }
2925
2926 static int test_blockdev_getro_0 (void)
2927 {
2928   /* InitEmpty for blockdev_getro (0) */
2929   {
2930     int r;
2931     suppress_error = 0;
2932     r = guestfs_umount_all (g);
2933     if (r == -1)
2934       return -1;
2935   }
2936   {
2937     int r;
2938     suppress_error = 0;
2939     r = guestfs_lvm_remove_all (g);
2940     if (r == -1)
2941       return -1;
2942   }
2943   /* TestOutputTrue for blockdev_getro (0) */
2944   {
2945     int r;
2946     suppress_error = 0;
2947     r = guestfs_blockdev_setro (g, "/dev/sda");
2948     if (r == -1)
2949       return -1;
2950   }
2951   {
2952     int r;
2953     suppress_error = 0;
2954     r = guestfs_blockdev_getro (g, "/dev/sda");
2955     if (r == -1)
2956       return -1;
2957     if (!r) {
2958       fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
2959       return -1;
2960     }
2961   }
2962   return 0;
2963 }
2964
2965 static int test_blockdev_setrw_0 (void)
2966 {
2967   /* InitEmpty for blockdev_setrw (0) */
2968   {
2969     int r;
2970     suppress_error = 0;
2971     r = guestfs_umount_all (g);
2972     if (r == -1)
2973       return -1;
2974   }
2975   {
2976     int r;
2977     suppress_error = 0;
2978     r = guestfs_lvm_remove_all (g);
2979     if (r == -1)
2980       return -1;
2981   }
2982   /* TestOutputFalse for blockdev_setrw (0) */
2983   {
2984     int r;
2985     suppress_error = 0;
2986     r = guestfs_blockdev_setrw (g, "/dev/sda");
2987     if (r == -1)
2988       return -1;
2989   }
2990   {
2991     int r;
2992     suppress_error = 0;
2993     r = guestfs_blockdev_getro (g, "/dev/sda");
2994     if (r == -1)
2995       return -1;
2996     if (r) {
2997       fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
2998       return -1;
2999     }
3000   }
3001   return 0;
3002 }
3003
3004 static int test_blockdev_setro_0 (void)
3005 {
3006   /* InitEmpty for blockdev_setro (0) */
3007   {
3008     int r;
3009     suppress_error = 0;
3010     r = guestfs_umount_all (g);
3011     if (r == -1)
3012       return -1;
3013   }
3014   {
3015     int r;
3016     suppress_error = 0;
3017     r = guestfs_lvm_remove_all (g);
3018     if (r == -1)
3019       return -1;
3020   }
3021   /* TestOutputTrue for blockdev_setro (0) */
3022   {
3023     int r;
3024     suppress_error = 0;
3025     r = guestfs_blockdev_setro (g, "/dev/sda");
3026     if (r == -1)
3027       return -1;
3028   }
3029   {
3030     int r;
3031     suppress_error = 0;
3032     r = guestfs_blockdev_getro (g, "/dev/sda");
3033     if (r == -1)
3034       return -1;
3035     if (!r) {
3036       fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
3037       return -1;
3038     }
3039   }
3040   return 0;
3041 }
3042
3043 static int test_statvfs_0 (void)
3044 {
3045   /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
3046   {
3047     int r;
3048     suppress_error = 0;
3049     r = guestfs_umount_all (g);
3050     if (r == -1)
3051       return -1;
3052   }
3053   {
3054     int r;
3055     suppress_error = 0;
3056     r = guestfs_lvm_remove_all (g);
3057     if (r == -1)
3058       return -1;
3059   }
3060   {
3061     char *lines[] = {
3062       ",",
3063       NULL
3064     };
3065     int r;
3066     suppress_error = 0;
3067     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3068     if (r == -1)
3069       return -1;
3070   }
3071   {
3072     int r;
3073     suppress_error = 0;
3074     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3075     if (r == -1)
3076       return -1;
3077   }
3078   {
3079     int r;
3080     suppress_error = 0;
3081     r = guestfs_mount (g, "/dev/sda1", "/");
3082     if (r == -1)
3083       return -1;
3084   }
3085   /* TestOutputStruct for statvfs (0) */
3086   {
3087     struct guestfs_statvfs *r;
3088     suppress_error = 0;
3089     r = guestfs_statvfs (g, "/");
3090     if (r == NULL)
3091       return -1;
3092     if (r->bfree != 487702) {
3093       fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
3094                (int) r->bfree);
3095       return -1;
3096     }
3097     if (r->blocks != 490020) {
3098       fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
3099                (int) r->blocks);
3100       return -1;
3101     }
3102     if (r->bsize != 1024) {
3103       fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
3104                (int) r->bsize);
3105       return -1;
3106     }
3107     free (r);
3108   }
3109   return 0;
3110 }
3111
3112 static int test_lstat_0 (void)
3113 {
3114   /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
3115   {
3116     int r;
3117     suppress_error = 0;
3118     r = guestfs_umount_all (g);
3119     if (r == -1)
3120       return -1;
3121   }
3122   {
3123     int r;
3124     suppress_error = 0;
3125     r = guestfs_lvm_remove_all (g);
3126     if (r == -1)
3127       return -1;
3128   }
3129   {
3130     char *lines[] = {
3131       ",",
3132       NULL
3133     };
3134     int r;
3135     suppress_error = 0;
3136     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3137     if (r == -1)
3138       return -1;
3139   }
3140   {
3141     int r;
3142     suppress_error = 0;
3143     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3144     if (r == -1)
3145       return -1;
3146   }
3147   {
3148     int r;
3149     suppress_error = 0;
3150     r = guestfs_mount (g, "/dev/sda1", "/");
3151     if (r == -1)
3152       return -1;
3153   }
3154   /* TestOutputStruct for lstat (0) */
3155   {
3156     int r;
3157     suppress_error = 0;
3158     r = guestfs_touch (g, "/new");
3159     if (r == -1)
3160       return -1;
3161   }
3162   {
3163     struct guestfs_stat *r;
3164     suppress_error = 0;
3165     r = guestfs_lstat (g, "/new");
3166     if (r == NULL)
3167       return -1;
3168     if (r->size != 0) {
3169       fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
3170                (int) r->size);
3171       return -1;
3172     }
3173     free (r);
3174   }
3175   return 0;
3176 }
3177
3178 static int test_stat_0 (void)
3179 {
3180   /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
3181   {
3182     int r;
3183     suppress_error = 0;
3184     r = guestfs_umount_all (g);
3185     if (r == -1)
3186       return -1;
3187   }
3188   {
3189     int r;
3190     suppress_error = 0;
3191     r = guestfs_lvm_remove_all (g);
3192     if (r == -1)
3193       return -1;
3194   }
3195   {
3196     char *lines[] = {
3197       ",",
3198       NULL
3199     };
3200     int r;
3201     suppress_error = 0;
3202     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3203     if (r == -1)
3204       return -1;
3205   }
3206   {
3207     int r;
3208     suppress_error = 0;
3209     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3210     if (r == -1)
3211       return -1;
3212   }
3213   {
3214     int r;
3215     suppress_error = 0;
3216     r = guestfs_mount (g, "/dev/sda1", "/");
3217     if (r == -1)
3218       return -1;
3219   }
3220   /* TestOutputStruct for stat (0) */
3221   {
3222     int r;
3223     suppress_error = 0;
3224     r = guestfs_touch (g, "/new");
3225     if (r == -1)
3226       return -1;
3227   }
3228   {
3229     struct guestfs_stat *r;
3230     suppress_error = 0;
3231     r = guestfs_stat (g, "/new");
3232     if (r == NULL)
3233       return -1;
3234     if (r->size != 0) {
3235       fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
3236                (int) r->size);
3237       return -1;
3238     }
3239     free (r);
3240   }
3241   return 0;
3242 }
3243
3244 static int test_file_0 (void)
3245 {
3246   /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
3247   {
3248     int r;
3249     suppress_error = 0;
3250     r = guestfs_umount_all (g);
3251     if (r == -1)
3252       return -1;
3253   }
3254   {
3255     int r;
3256     suppress_error = 0;
3257     r = guestfs_lvm_remove_all (g);
3258     if (r == -1)
3259       return -1;
3260   }
3261   {
3262     char *lines[] = {
3263       ",",
3264       NULL
3265     };
3266     int r;
3267     suppress_error = 0;
3268     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3269     if (r == -1)
3270       return -1;
3271   }
3272   {
3273     int r;
3274     suppress_error = 0;
3275     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3276     if (r == -1)
3277       return -1;
3278   }
3279   {
3280     int r;
3281     suppress_error = 0;
3282     r = guestfs_mount (g, "/dev/sda1", "/");
3283     if (r == -1)
3284       return -1;
3285   }
3286   /* TestOutput for file (0) */
3287   {
3288     int r;
3289     suppress_error = 0;
3290     r = guestfs_touch (g, "/new");
3291     if (r == -1)
3292       return -1;
3293   }
3294   {
3295     char *r;
3296     suppress_error = 0;
3297     r = guestfs_file (g, "/new");
3298     if (r == NULL)
3299       return -1;
3300     if (strcmp (r, "empty") != 0) {
3301       fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
3302       return -1;
3303     }
3304     free (r);
3305   }
3306   return 0;
3307 }
3308
3309 static int test_file_1 (void)
3310 {
3311   /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
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 *lines[] = {
3328       ",",
3329       NULL
3330     };
3331     int r;
3332     suppress_error = 0;
3333     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3334     if (r == -1)
3335       return -1;
3336   }
3337   {
3338     int r;
3339     suppress_error = 0;
3340     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3341     if (r == -1)
3342       return -1;
3343   }
3344   {
3345     int r;
3346     suppress_error = 0;
3347     r = guestfs_mount (g, "/dev/sda1", "/");
3348     if (r == -1)
3349       return -1;
3350   }
3351   /* TestOutput for file (1) */
3352   {
3353     int r;
3354     suppress_error = 0;
3355     r = guestfs_write_file (g, "/new", "some content\n", 0);
3356     if (r == -1)
3357       return -1;
3358   }
3359   {
3360     char *r;
3361     suppress_error = 0;
3362     r = guestfs_file (g, "/new");
3363     if (r == NULL)
3364       return -1;
3365     if (strcmp (r, "ASCII text") != 0) {
3366       fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
3367       return -1;
3368     }
3369     free (r);
3370   }
3371   return 0;
3372 }
3373
3374 static int test_file_2 (void)
3375 {
3376   /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
3377   {
3378     int r;
3379     suppress_error = 0;
3380     r = guestfs_umount_all (g);
3381     if (r == -1)
3382       return -1;
3383   }
3384   {
3385     int r;
3386     suppress_error = 0;
3387     r = guestfs_lvm_remove_all (g);
3388     if (r == -1)
3389       return -1;
3390   }
3391   {
3392     char *lines[] = {
3393       ",",
3394       NULL
3395     };
3396     int r;
3397     suppress_error = 0;
3398     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3399     if (r == -1)
3400       return -1;
3401   }
3402   {
3403     int r;
3404     suppress_error = 0;
3405     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3406     if (r == -1)
3407       return -1;
3408   }
3409   {
3410     int r;
3411     suppress_error = 0;
3412     r = guestfs_mount (g, "/dev/sda1", "/");
3413     if (r == -1)
3414       return -1;
3415   }
3416   /* TestLastFail for file (2) */
3417   {
3418     char *r;
3419     suppress_error = 1;
3420     r = guestfs_file (g, "/nofile");
3421     if (r != NULL)
3422       return -1;
3423     free (r);
3424   }
3425   return 0;
3426 }
3427
3428 static int test_umount_all_0 (void)
3429 {
3430   /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
3431   {
3432     int r;
3433     suppress_error = 0;
3434     r = guestfs_umount_all (g);
3435     if (r == -1)
3436       return -1;
3437   }
3438   {
3439     int r;
3440     suppress_error = 0;
3441     r = guestfs_lvm_remove_all (g);
3442     if (r == -1)
3443       return -1;
3444   }
3445   {
3446     char *lines[] = {
3447       ",",
3448       NULL
3449     };
3450     int r;
3451     suppress_error = 0;
3452     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3453     if (r == -1)
3454       return -1;
3455   }
3456   {
3457     int r;
3458     suppress_error = 0;
3459     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3460     if (r == -1)
3461       return -1;
3462   }
3463   {
3464     int r;
3465     suppress_error = 0;
3466     r = guestfs_mount (g, "/dev/sda1", "/");
3467     if (r == -1)
3468       return -1;
3469   }
3470   /* TestOutputList for umount_all (0) */
3471   {
3472     int r;
3473     suppress_error = 0;
3474     r = guestfs_umount_all (g);
3475     if (r == -1)
3476       return -1;
3477   }
3478   {
3479     char **r;
3480     int i;
3481     suppress_error = 0;
3482     r = guestfs_mounts (g);
3483     if (r == NULL)
3484       return -1;
3485     if (r[0] != NULL) {
3486       fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
3487       print_strings (r);
3488       return -1;
3489     }
3490     for (i = 0; r[i] != NULL; ++i)
3491       free (r[i]);
3492     free (r);
3493   }
3494   return 0;
3495 }
3496
3497 static int test_umount_all_1 (void)
3498 {
3499   /* InitEmpty for umount_all (1) */
3500   {
3501     int r;
3502     suppress_error = 0;
3503     r = guestfs_umount_all (g);
3504     if (r == -1)
3505       return -1;
3506   }
3507   {
3508     int r;
3509     suppress_error = 0;
3510     r = guestfs_lvm_remove_all (g);
3511     if (r == -1)
3512       return -1;
3513   }
3514   /* TestOutputList for umount_all (1) */
3515   {
3516     char *lines[] = {
3517       ",10",
3518       ",20",
3519       ",",
3520       NULL
3521     };
3522     int r;
3523     suppress_error = 0;
3524     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3525     if (r == -1)
3526       return -1;
3527   }
3528   {
3529     int r;
3530     suppress_error = 0;
3531     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3532     if (r == -1)
3533       return -1;
3534   }
3535   {
3536     int r;
3537     suppress_error = 0;
3538     r = guestfs_mkfs (g, "ext2", "/dev/sda2");
3539     if (r == -1)
3540       return -1;
3541   }
3542   {
3543     int r;
3544     suppress_error = 0;
3545     r = guestfs_mkfs (g, "ext2", "/dev/sda3");
3546     if (r == -1)
3547       return -1;
3548   }
3549   {
3550     int r;
3551     suppress_error = 0;
3552     r = guestfs_mount (g, "/dev/sda1", "/");
3553     if (r == -1)
3554       return -1;
3555   }
3556   {
3557     int r;
3558     suppress_error = 0;
3559     r = guestfs_mkdir (g, "/mp1");
3560     if (r == -1)
3561       return -1;
3562   }
3563   {
3564     int r;
3565     suppress_error = 0;
3566     r = guestfs_mount (g, "/dev/sda2", "/mp1");
3567     if (r == -1)
3568       return -1;
3569   }
3570   {
3571     int r;
3572     suppress_error = 0;
3573     r = guestfs_mkdir (g, "/mp1/mp2");
3574     if (r == -1)
3575       return -1;
3576   }
3577   {
3578     int r;
3579     suppress_error = 0;
3580     r = guestfs_mount (g, "/dev/sda3", "/mp1/mp2");
3581     if (r == -1)
3582       return -1;
3583   }
3584   {
3585     int r;
3586     suppress_error = 0;
3587     r = guestfs_mkdir (g, "/mp1/mp2/mp3");
3588     if (r == -1)
3589       return -1;
3590   }
3591   {
3592     int r;
3593     suppress_error = 0;
3594     r = guestfs_umount_all (g);
3595     if (r == -1)
3596       return -1;
3597   }
3598   {
3599     char **r;
3600     int i;
3601     suppress_error = 0;
3602     r = guestfs_mounts (g);
3603     if (r == NULL)
3604       return -1;
3605     if (r[0] != NULL) {
3606       fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
3607       print_strings (r);
3608       return -1;
3609     }
3610     for (i = 0; r[i] != NULL; ++i)
3611       free (r[i]);
3612     free (r);
3613   }
3614   return 0;
3615 }
3616
3617 static int test_mounts_0 (void)
3618 {
3619   /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
3620   {
3621     int r;
3622     suppress_error = 0;
3623     r = guestfs_umount_all (g);
3624     if (r == -1)
3625       return -1;
3626   }
3627   {
3628     int r;
3629     suppress_error = 0;
3630     r = guestfs_lvm_remove_all (g);
3631     if (r == -1)
3632       return -1;
3633   }
3634   {
3635     char *lines[] = {
3636       ",",
3637       NULL
3638     };
3639     int r;
3640     suppress_error = 0;
3641     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3642     if (r == -1)
3643       return -1;
3644   }
3645   {
3646     int r;
3647     suppress_error = 0;
3648     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3649     if (r == -1)
3650       return -1;
3651   }
3652   {
3653     int r;
3654     suppress_error = 0;
3655     r = guestfs_mount (g, "/dev/sda1", "/");
3656     if (r == -1)
3657       return -1;
3658   }
3659   /* TestOutputList for mounts (0) */
3660   {
3661     char **r;
3662     int i;
3663     suppress_error = 0;
3664     r = guestfs_mounts (g);
3665     if (r == NULL)
3666       return -1;
3667     if (!r[0]) {
3668       fprintf (stderr, "test_mounts_0: short list returned from command\n");
3669       print_strings (r);
3670       return -1;
3671     }
3672     if (strcmp (r[0], "/dev/sda1") != 0) {
3673       fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3674       return -1;
3675     }
3676     if (r[1] != NULL) {
3677       fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
3678       print_strings (r);
3679       return -1;
3680     }
3681     for (i = 0; r[i] != NULL; ++i)
3682       free (r[i]);
3683     free (r);
3684   }
3685   return 0;
3686 }
3687
3688 static int test_umount_0 (void)
3689 {
3690   /* InitEmpty for umount (0) */
3691   {
3692     int r;
3693     suppress_error = 0;
3694     r = guestfs_umount_all (g);
3695     if (r == -1)
3696       return -1;
3697   }
3698   {
3699     int r;
3700     suppress_error = 0;
3701     r = guestfs_lvm_remove_all (g);
3702     if (r == -1)
3703       return -1;
3704   }
3705   /* TestOutputList for umount (0) */
3706   {
3707     char *lines[] = {
3708       ",",
3709       NULL
3710     };
3711     int r;
3712     suppress_error = 0;
3713     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3714     if (r == -1)
3715       return -1;
3716   }
3717   {
3718     int r;
3719     suppress_error = 0;
3720     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3721     if (r == -1)
3722       return -1;
3723   }
3724   {
3725     int r;
3726     suppress_error = 0;
3727     r = guestfs_mount (g, "/dev/sda1", "/");
3728     if (r == -1)
3729       return -1;
3730   }
3731   {
3732     char **r;
3733     int i;
3734     suppress_error = 0;
3735     r = guestfs_mounts (g);
3736     if (r == NULL)
3737       return -1;
3738     if (!r[0]) {
3739       fprintf (stderr, "test_umount_0: short list returned from command\n");
3740       print_strings (r);
3741       return -1;
3742     }
3743     if (strcmp (r[0], "/dev/sda1") != 0) {
3744       fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3745       return -1;
3746     }
3747     if (r[1] != NULL) {
3748       fprintf (stderr, "test_umount_0: extra elements returned from command\n");
3749       print_strings (r);
3750       return -1;
3751     }
3752     for (i = 0; r[i] != NULL; ++i)
3753       free (r[i]);
3754     free (r);
3755   }
3756   return 0;
3757 }
3758
3759 static int test_umount_1 (void)
3760 {
3761   /* InitEmpty for umount (1) */
3762   {
3763     int r;
3764     suppress_error = 0;
3765     r = guestfs_umount_all (g);
3766     if (r == -1)
3767       return -1;
3768   }
3769   {
3770     int r;
3771     suppress_error = 0;
3772     r = guestfs_lvm_remove_all (g);
3773     if (r == -1)
3774       return -1;
3775   }
3776   /* TestOutputList for umount (1) */
3777   {
3778     char *lines[] = {
3779       ",",
3780       NULL
3781     };
3782     int r;
3783     suppress_error = 0;
3784     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3785     if (r == -1)
3786       return -1;
3787   }
3788   {
3789     int r;
3790     suppress_error = 0;
3791     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3792     if (r == -1)
3793       return -1;
3794   }
3795   {
3796     int r;
3797     suppress_error = 0;
3798     r = guestfs_mount (g, "/dev/sda1", "/");
3799     if (r == -1)
3800       return -1;
3801   }
3802   {
3803     int r;
3804     suppress_error = 0;
3805     r = guestfs_umount (g, "/");
3806     if (r == -1)
3807       return -1;
3808   }
3809   {
3810     char **r;
3811     int i;
3812     suppress_error = 0;
3813     r = guestfs_mounts (g);
3814     if (r == NULL)
3815       return -1;
3816     if (r[0] != NULL) {
3817       fprintf (stderr, "test_umount_1: extra elements returned from command\n");
3818       print_strings (r);
3819       return -1;
3820     }
3821     for (i = 0; r[i] != NULL; ++i)
3822       free (r[i]);
3823     free (r);
3824   }
3825   return 0;
3826 }
3827
3828 static int test_write_file_0 (void)
3829 {
3830   /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
3831   {
3832     int r;
3833     suppress_error = 0;
3834     r = guestfs_umount_all (g);
3835     if (r == -1)
3836       return -1;
3837   }
3838   {
3839     int r;
3840     suppress_error = 0;
3841     r = guestfs_lvm_remove_all (g);
3842     if (r == -1)
3843       return -1;
3844   }
3845   {
3846     char *lines[] = {
3847       ",",
3848       NULL
3849     };
3850     int r;
3851     suppress_error = 0;
3852     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3853     if (r == -1)
3854       return -1;
3855   }
3856   {
3857     int r;
3858     suppress_error = 0;
3859     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3860     if (r == -1)
3861       return -1;
3862   }
3863   {
3864     int r;
3865     suppress_error = 0;
3866     r = guestfs_mount (g, "/dev/sda1", "/");
3867     if (r == -1)
3868       return -1;
3869   }
3870   /* TestOutput for write_file (0) */
3871   {
3872     int r;
3873     suppress_error = 0;
3874     r = guestfs_write_file (g, "/new", "new file contents", 0);
3875     if (r == -1)
3876       return -1;
3877   }
3878   {
3879     char *r;
3880     suppress_error = 0;
3881     r = guestfs_cat (g, "/new");
3882     if (r == NULL)
3883       return -1;
3884     if (strcmp (r, "new file contents") != 0) {
3885       fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
3886       return -1;
3887     }
3888     free (r);
3889   }
3890   return 0;
3891 }
3892
3893 static int test_write_file_1 (void)
3894 {
3895   /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
3896   {
3897     int r;
3898     suppress_error = 0;
3899     r = guestfs_umount_all (g);
3900     if (r == -1)
3901       return -1;
3902   }
3903   {
3904     int r;
3905     suppress_error = 0;
3906     r = guestfs_lvm_remove_all (g);
3907     if (r == -1)
3908       return -1;
3909   }
3910   {
3911     char *lines[] = {
3912       ",",
3913       NULL
3914     };
3915     int r;
3916     suppress_error = 0;
3917     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3918     if (r == -1)
3919       return -1;
3920   }
3921   {
3922     int r;
3923     suppress_error = 0;
3924     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3925     if (r == -1)
3926       return -1;
3927   }
3928   {
3929     int r;
3930     suppress_error = 0;
3931     r = guestfs_mount (g, "/dev/sda1", "/");
3932     if (r == -1)
3933       return -1;
3934   }
3935   /* TestOutput for write_file (1) */
3936   {
3937     int r;
3938     suppress_error = 0;
3939     r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
3940     if (r == -1)
3941       return -1;
3942   }
3943   {
3944     char *r;
3945     suppress_error = 0;
3946     r = guestfs_cat (g, "/new");
3947     if (r == NULL)
3948       return -1;
3949     if (strcmp (r, "\nnew file contents\n") != 0) {
3950       fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
3951       return -1;
3952     }
3953     free (r);
3954   }
3955   return 0;
3956 }
3957
3958 static int test_write_file_2 (void)
3959 {
3960   /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
3961   {
3962     int r;
3963     suppress_error = 0;
3964     r = guestfs_umount_all (g);
3965     if (r == -1)
3966       return -1;
3967   }
3968   {
3969     int r;
3970     suppress_error = 0;
3971     r = guestfs_lvm_remove_all (g);
3972     if (r == -1)
3973       return -1;
3974   }
3975   {
3976     char *lines[] = {
3977       ",",
3978       NULL
3979     };
3980     int r;
3981     suppress_error = 0;
3982     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3983     if (r == -1)
3984       return -1;
3985   }
3986   {
3987     int r;
3988     suppress_error = 0;
3989     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3990     if (r == -1)
3991       return -1;
3992   }
3993   {
3994     int r;
3995     suppress_error = 0;
3996     r = guestfs_mount (g, "/dev/sda1", "/");
3997     if (r == -1)
3998       return -1;
3999   }
4000   /* TestOutput for write_file (2) */
4001   {
4002     int r;
4003     suppress_error = 0;
4004     r = guestfs_write_file (g, "/new", "\n\n", 0);
4005     if (r == -1)
4006       return -1;
4007   }
4008   {
4009     char *r;
4010     suppress_error = 0;
4011     r = guestfs_cat (g, "/new");
4012     if (r == NULL)
4013       return -1;
4014     if (strcmp (r, "\n\n") != 0) {
4015       fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
4016       return -1;
4017     }
4018     free (r);
4019   }
4020   return 0;
4021 }
4022
4023 static int test_write_file_3 (void)
4024 {
4025   /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
4026   {
4027     int r;
4028     suppress_error = 0;
4029     r = guestfs_umount_all (g);
4030     if (r == -1)
4031       return -1;
4032   }
4033   {
4034     int r;
4035     suppress_error = 0;
4036     r = guestfs_lvm_remove_all (g);
4037     if (r == -1)
4038       return -1;
4039   }
4040   {
4041     char *lines[] = {
4042       ",",
4043       NULL
4044     };
4045     int r;
4046     suppress_error = 0;
4047     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4048     if (r == -1)
4049       return -1;
4050   }
4051   {
4052     int r;
4053     suppress_error = 0;
4054     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4055     if (r == -1)
4056       return -1;
4057   }
4058   {
4059     int r;
4060     suppress_error = 0;
4061     r = guestfs_mount (g, "/dev/sda1", "/");
4062     if (r == -1)
4063       return -1;
4064   }
4065   /* TestOutput for write_file (3) */
4066   {
4067     int r;
4068     suppress_error = 0;
4069     r = guestfs_write_file (g, "/new", "", 0);
4070     if (r == -1)
4071       return -1;
4072   }
4073   {
4074     char *r;
4075     suppress_error = 0;
4076     r = guestfs_cat (g, "/new");
4077     if (r == NULL)
4078       return -1;
4079     if (strcmp (r, "") != 0) {
4080       fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
4081       return -1;
4082     }
4083     free (r);
4084   }
4085   return 0;
4086 }
4087
4088 static int test_write_file_4 (void)
4089 {
4090   /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
4091   {
4092     int r;
4093     suppress_error = 0;
4094     r = guestfs_umount_all (g);
4095     if (r == -1)
4096       return -1;
4097   }
4098   {
4099     int r;
4100     suppress_error = 0;
4101     r = guestfs_lvm_remove_all (g);
4102     if (r == -1)
4103       return -1;
4104   }
4105   {
4106     char *lines[] = {
4107       ",",
4108       NULL
4109     };
4110     int r;
4111     suppress_error = 0;
4112     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4113     if (r == -1)
4114       return -1;
4115   }
4116   {
4117     int r;
4118     suppress_error = 0;
4119     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4120     if (r == -1)
4121       return -1;
4122   }
4123   {
4124     int r;
4125     suppress_error = 0;
4126     r = guestfs_mount (g, "/dev/sda1", "/");
4127     if (r == -1)
4128       return -1;
4129   }
4130   /* TestOutput for write_file (4) */
4131   {
4132     int r;
4133     suppress_error = 0;
4134     r = guestfs_write_file (g, "/new", "\n\n\n", 0);
4135     if (r == -1)
4136       return -1;
4137   }
4138   {
4139     char *r;
4140     suppress_error = 0;
4141     r = guestfs_cat (g, "/new");
4142     if (r == NULL)
4143       return -1;
4144     if (strcmp (r, "\n\n\n") != 0) {
4145       fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
4146       return -1;
4147     }
4148     free (r);
4149   }
4150   return 0;
4151 }
4152
4153 static int test_write_file_5 (void)
4154 {
4155   /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
4156   {
4157     int r;
4158     suppress_error = 0;
4159     r = guestfs_umount_all (g);
4160     if (r == -1)
4161       return -1;
4162   }
4163   {
4164     int r;
4165     suppress_error = 0;
4166     r = guestfs_lvm_remove_all (g);
4167     if (r == -1)
4168       return -1;
4169   }
4170   {
4171     char *lines[] = {
4172       ",",
4173       NULL
4174     };
4175     int r;
4176     suppress_error = 0;
4177     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4178     if (r == -1)
4179       return -1;
4180   }
4181   {
4182     int r;
4183     suppress_error = 0;
4184     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4185     if (r == -1)
4186       return -1;
4187   }
4188   {
4189     int r;
4190     suppress_error = 0;
4191     r = guestfs_mount (g, "/dev/sda1", "/");
4192     if (r == -1)
4193       return -1;
4194   }
4195   /* TestOutput for write_file (5) */
4196   {
4197     int r;
4198     suppress_error = 0;
4199     r = guestfs_write_file (g, "/new", "\n", 0);
4200     if (r == -1)
4201       return -1;
4202   }
4203   {
4204     char *r;
4205     suppress_error = 0;
4206     r = guestfs_cat (g, "/new");
4207     if (r == NULL)
4208       return -1;
4209     if (strcmp (r, "\n") != 0) {
4210       fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
4211       return -1;
4212     }
4213     free (r);
4214   }
4215   return 0;
4216 }
4217
4218 static int test_mkfs_0 (void)
4219 {
4220   /* InitEmpty for mkfs (0) */
4221   {
4222     int r;
4223     suppress_error = 0;
4224     r = guestfs_umount_all (g);
4225     if (r == -1)
4226       return -1;
4227   }
4228   {
4229     int r;
4230     suppress_error = 0;
4231     r = guestfs_lvm_remove_all (g);
4232     if (r == -1)
4233       return -1;
4234   }
4235   /* TestOutput for mkfs (0) */
4236   {
4237     char *lines[] = {
4238       ",",
4239       NULL
4240     };
4241     int r;
4242     suppress_error = 0;
4243     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4244     if (r == -1)
4245       return -1;
4246   }
4247   {
4248     int r;
4249     suppress_error = 0;
4250     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4251     if (r == -1)
4252       return -1;
4253   }
4254   {
4255     int r;
4256     suppress_error = 0;
4257     r = guestfs_mount (g, "/dev/sda1", "/");
4258     if (r == -1)
4259       return -1;
4260   }
4261   {
4262     int r;
4263     suppress_error = 0;
4264     r = guestfs_write_file (g, "/new", "new file contents", 0);
4265     if (r == -1)
4266       return -1;
4267   }
4268   {
4269     char *r;
4270     suppress_error = 0;
4271     r = guestfs_cat (g, "/new");
4272     if (r == NULL)
4273       return -1;
4274     if (strcmp (r, "new file contents") != 0) {
4275       fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
4276       return -1;
4277     }
4278     free (r);
4279   }
4280   return 0;
4281 }
4282
4283 static int test_lvcreate_0 (void)
4284 {
4285   /* InitEmpty for lvcreate (0) */
4286   {
4287     int r;
4288     suppress_error = 0;
4289     r = guestfs_umount_all (g);
4290     if (r == -1)
4291       return -1;
4292   }
4293   {
4294     int r;
4295     suppress_error = 0;
4296     r = guestfs_lvm_remove_all (g);
4297     if (r == -1)
4298       return -1;
4299   }
4300   /* TestOutputList for lvcreate (0) */
4301   {
4302     char *lines[] = {
4303       ",10",
4304       ",20",
4305       ",",
4306       NULL
4307     };
4308     int r;
4309     suppress_error = 0;
4310     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4311     if (r == -1)
4312       return -1;
4313   }
4314   {
4315     int r;
4316     suppress_error = 0;
4317     r = guestfs_pvcreate (g, "/dev/sda1");
4318     if (r == -1)
4319       return -1;
4320   }
4321   {
4322     int r;
4323     suppress_error = 0;
4324     r = guestfs_pvcreate (g, "/dev/sda2");
4325     if (r == -1)
4326       return -1;
4327   }
4328   {
4329     int r;
4330     suppress_error = 0;
4331     r = guestfs_pvcreate (g, "/dev/sda3");
4332     if (r == -1)
4333       return -1;
4334   }
4335   {
4336     char *physvols[] = {
4337       "/dev/sda1",
4338       "/dev/sda2",
4339       NULL
4340     };
4341     int r;
4342     suppress_error = 0;
4343     r = guestfs_vgcreate (g, "VG1", physvols);
4344     if (r == -1)
4345       return -1;
4346   }
4347   {
4348     char *physvols[] = {
4349       "/dev/sda3",
4350       NULL
4351     };
4352     int r;
4353     suppress_error = 0;
4354     r = guestfs_vgcreate (g, "VG2", physvols);
4355     if (r == -1)
4356       return -1;
4357   }
4358   {
4359     int r;
4360     suppress_error = 0;
4361     r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4362     if (r == -1)
4363       return -1;
4364   }
4365   {
4366     int r;
4367     suppress_error = 0;
4368     r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4369     if (r == -1)
4370       return -1;
4371   }
4372   {
4373     int r;
4374     suppress_error = 0;
4375     r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4376     if (r == -1)
4377       return -1;
4378   }
4379   {
4380     int r;
4381     suppress_error = 0;
4382     r = guestfs_lvcreate (g, "LV4", "VG2", 50);
4383     if (r == -1)
4384       return -1;
4385   }
4386   {
4387     int r;
4388     suppress_error = 0;
4389     r = guestfs_lvcreate (g, "LV5", "VG2", 50);
4390     if (r == -1)
4391       return -1;
4392   }
4393   {
4394     char **r;
4395     int i;
4396     suppress_error = 0;
4397     r = guestfs_lvs (g);
4398     if (r == NULL)
4399       return -1;
4400     if (!r[0]) {
4401       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4402       print_strings (r);
4403       return -1;
4404     }
4405     if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4406       fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4407       return -1;
4408     }
4409     if (!r[1]) {
4410       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4411       print_strings (r);
4412       return -1;
4413     }
4414     if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4415       fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4416       return -1;
4417     }
4418     if (!r[2]) {
4419       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4420       print_strings (r);
4421       return -1;
4422     }
4423     if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4424       fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4425       return -1;
4426     }
4427     if (!r[3]) {
4428       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4429       print_strings (r);
4430       return -1;
4431     }
4432     if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
4433       fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
4434       return -1;
4435     }
4436     if (!r[4]) {
4437       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4438       print_strings (r);
4439       return -1;
4440     }
4441     if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
4442       fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
4443       return -1;
4444     }
4445     if (r[5] != NULL) {
4446       fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
4447       print_strings (r);
4448       return -1;
4449     }
4450     for (i = 0; r[i] != NULL; ++i)
4451       free (r[i]);
4452     free (r);
4453   }
4454   return 0;
4455 }
4456
4457 static int test_vgcreate_0 (void)
4458 {
4459   /* InitEmpty for vgcreate (0) */
4460   {
4461     int r;
4462     suppress_error = 0;
4463     r = guestfs_umount_all (g);
4464     if (r == -1)
4465       return -1;
4466   }
4467   {
4468     int r;
4469     suppress_error = 0;
4470     r = guestfs_lvm_remove_all (g);
4471     if (r == -1)
4472       return -1;
4473   }
4474   /* TestOutputList for vgcreate (0) */
4475   {
4476     char *lines[] = {
4477       ",10",
4478       ",20",
4479       ",",
4480       NULL
4481     };
4482     int r;
4483     suppress_error = 0;
4484     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4485     if (r == -1)
4486       return -1;
4487   }
4488   {
4489     int r;
4490     suppress_error = 0;
4491     r = guestfs_pvcreate (g, "/dev/sda1");
4492     if (r == -1)
4493       return -1;
4494   }
4495   {
4496     int r;
4497     suppress_error = 0;
4498     r = guestfs_pvcreate (g, "/dev/sda2");
4499     if (r == -1)
4500       return -1;
4501   }
4502   {
4503     int r;
4504     suppress_error = 0;
4505     r = guestfs_pvcreate (g, "/dev/sda3");
4506     if (r == -1)
4507       return -1;
4508   }
4509   {
4510     char *physvols[] = {
4511       "/dev/sda1",
4512       "/dev/sda2",
4513       NULL
4514     };
4515     int r;
4516     suppress_error = 0;
4517     r = guestfs_vgcreate (g, "VG1", physvols);
4518     if (r == -1)
4519       return -1;
4520   }
4521   {
4522     char *physvols[] = {
4523       "/dev/sda3",
4524       NULL
4525     };
4526     int r;
4527     suppress_error = 0;
4528     r = guestfs_vgcreate (g, "VG2", physvols);
4529     if (r == -1)
4530       return -1;
4531   }
4532   {
4533     char **r;
4534     int i;
4535     suppress_error = 0;
4536     r = guestfs_vgs (g);
4537     if (r == NULL)
4538       return -1;
4539     if (!r[0]) {
4540       fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4541       print_strings (r);
4542       return -1;
4543     }
4544     if (strcmp (r[0], "VG1") != 0) {
4545       fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
4546       return -1;
4547     }
4548     if (!r[1]) {
4549       fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4550       print_strings (r);
4551       return -1;
4552     }
4553     if (strcmp (r[1], "VG2") != 0) {
4554       fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
4555       return -1;
4556     }
4557     if (r[2] != NULL) {
4558       fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
4559       print_strings (r);
4560       return -1;
4561     }
4562     for (i = 0; r[i] != NULL; ++i)
4563       free (r[i]);
4564     free (r);
4565   }
4566   return 0;
4567 }
4568
4569 static int test_pvcreate_0 (void)
4570 {
4571   /* InitEmpty for pvcreate (0) */
4572   {
4573     int r;
4574     suppress_error = 0;
4575     r = guestfs_umount_all (g);
4576     if (r == -1)
4577       return -1;
4578   }
4579   {
4580     int r;
4581     suppress_error = 0;
4582     r = guestfs_lvm_remove_all (g);
4583     if (r == -1)
4584       return -1;
4585   }
4586   /* TestOutputList for pvcreate (0) */
4587   {
4588     char *lines[] = {
4589       ",10",
4590       ",20",
4591       ",",
4592       NULL
4593     };
4594     int r;
4595     suppress_error = 0;
4596     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4597     if (r == -1)
4598       return -1;
4599   }
4600   {
4601     int r;
4602     suppress_error = 0;
4603     r = guestfs_pvcreate (g, "/dev/sda1");
4604     if (r == -1)
4605       return -1;
4606   }
4607   {
4608     int r;
4609     suppress_error = 0;
4610     r = guestfs_pvcreate (g, "/dev/sda2");
4611     if (r == -1)
4612       return -1;
4613   }
4614   {
4615     int r;
4616     suppress_error = 0;
4617     r = guestfs_pvcreate (g, "/dev/sda3");
4618     if (r == -1)
4619       return -1;
4620   }
4621   {
4622     char **r;
4623     int i;
4624     suppress_error = 0;
4625     r = guestfs_pvs (g);
4626     if (r == NULL)
4627       return -1;
4628     if (!r[0]) {
4629       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4630       print_strings (r);
4631       return -1;
4632     }
4633     if (strcmp (r[0], "/dev/sda1") != 0) {
4634       fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4635       return -1;
4636     }
4637     if (!r[1]) {
4638       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4639       print_strings (r);
4640       return -1;
4641     }
4642     if (strcmp (r[1], "/dev/sda2") != 0) {
4643       fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4644       return -1;
4645     }
4646     if (!r[2]) {
4647       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4648       print_strings (r);
4649       return -1;
4650     }
4651     if (strcmp (r[2], "/dev/sda3") != 0) {
4652       fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4653       return -1;
4654     }
4655     if (r[3] != NULL) {
4656       fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
4657       print_strings (r);
4658       return -1;
4659     }
4660     for (i = 0; r[i] != NULL; ++i)
4661       free (r[i]);
4662     free (r);
4663   }
4664   return 0;
4665 }
4666
4667 static int test_is_dir_0 (void)
4668 {
4669   /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
4670   {
4671     int r;
4672     suppress_error = 0;
4673     r = guestfs_umount_all (g);
4674     if (r == -1)
4675       return -1;
4676   }
4677   {
4678     int r;
4679     suppress_error = 0;
4680     r = guestfs_lvm_remove_all (g);
4681     if (r == -1)
4682       return -1;
4683   }
4684   {
4685     char *lines[] = {
4686       ",",
4687       NULL
4688     };
4689     int r;
4690     suppress_error = 0;
4691     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4692     if (r == -1)
4693       return -1;
4694   }
4695   {
4696     int r;
4697     suppress_error = 0;
4698     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4699     if (r == -1)
4700       return -1;
4701   }
4702   {
4703     int r;
4704     suppress_error = 0;
4705     r = guestfs_mount (g, "/dev/sda1", "/");
4706     if (r == -1)
4707       return -1;
4708   }
4709   /* TestOutputFalse for is_dir (0) */
4710   {
4711     int r;
4712     suppress_error = 0;
4713     r = guestfs_touch (g, "/new");
4714     if (r == -1)
4715       return -1;
4716   }
4717   {
4718     int r;
4719     suppress_error = 0;
4720     r = guestfs_is_dir (g, "/new");
4721     if (r == -1)
4722       return -1;
4723     if (r) {
4724       fprintf (stderr, "test_is_dir_0: expected false, got true\n");
4725       return -1;
4726     }
4727   }
4728   return 0;
4729 }
4730
4731 static int test_is_dir_1 (void)
4732 {
4733   /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
4734   {
4735     int r;
4736     suppress_error = 0;
4737     r = guestfs_umount_all (g);
4738     if (r == -1)
4739       return -1;
4740   }
4741   {
4742     int r;
4743     suppress_error = 0;
4744     r = guestfs_lvm_remove_all (g);
4745     if (r == -1)
4746       return -1;
4747   }
4748   {
4749     char *lines[] = {
4750       ",",
4751       NULL
4752     };
4753     int r;
4754     suppress_error = 0;
4755     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4756     if (r == -1)
4757       return -1;
4758   }
4759   {
4760     int r;
4761     suppress_error = 0;
4762     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4763     if (r == -1)
4764       return -1;
4765   }
4766   {
4767     int r;
4768     suppress_error = 0;
4769     r = guestfs_mount (g, "/dev/sda1", "/");
4770     if (r == -1)
4771       return -1;
4772   }
4773   /* TestOutputTrue for is_dir (1) */
4774   {
4775     int r;
4776     suppress_error = 0;
4777     r = guestfs_mkdir (g, "/new");
4778     if (r == -1)
4779       return -1;
4780   }
4781   {
4782     int r;
4783     suppress_error = 0;
4784     r = guestfs_is_dir (g, "/new");
4785     if (r == -1)
4786       return -1;
4787     if (!r) {
4788       fprintf (stderr, "test_is_dir_1: expected true, got false\n");
4789       return -1;
4790     }
4791   }
4792   return 0;
4793 }
4794
4795 static int test_is_file_0 (void)
4796 {
4797   /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
4798   {
4799     int r;
4800     suppress_error = 0;
4801     r = guestfs_umount_all (g);
4802     if (r == -1)
4803       return -1;
4804   }
4805   {
4806     int r;
4807     suppress_error = 0;
4808     r = guestfs_lvm_remove_all (g);
4809     if (r == -1)
4810       return -1;
4811   }
4812   {
4813     char *lines[] = {
4814       ",",
4815       NULL
4816     };
4817     int r;
4818     suppress_error = 0;
4819     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4820     if (r == -1)
4821       return -1;
4822   }
4823   {
4824     int r;
4825     suppress_error = 0;
4826     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4827     if (r == -1)
4828       return -1;
4829   }
4830   {
4831     int r;
4832     suppress_error = 0;
4833     r = guestfs_mount (g, "/dev/sda1", "/");
4834     if (r == -1)
4835       return -1;
4836   }
4837   /* TestOutputTrue for is_file (0) */
4838   {
4839     int r;
4840     suppress_error = 0;
4841     r = guestfs_touch (g, "/new");
4842     if (r == -1)
4843       return -1;
4844   }
4845   {
4846     int r;
4847     suppress_error = 0;
4848     r = guestfs_is_file (g, "/new");
4849     if (r == -1)
4850       return -1;
4851     if (!r) {
4852       fprintf (stderr, "test_is_file_0: expected true, got false\n");
4853       return -1;
4854     }
4855   }
4856   return 0;
4857 }
4858
4859 static int test_is_file_1 (void)
4860 {
4861   /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
4862   {
4863     int r;
4864     suppress_error = 0;
4865     r = guestfs_umount_all (g);
4866     if (r == -1)
4867       return -1;
4868   }
4869   {
4870     int r;
4871     suppress_error = 0;
4872     r = guestfs_lvm_remove_all (g);
4873     if (r == -1)
4874       return -1;
4875   }
4876   {
4877     char *lines[] = {
4878       ",",
4879       NULL
4880     };
4881     int r;
4882     suppress_error = 0;
4883     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4884     if (r == -1)
4885       return -1;
4886   }
4887   {
4888     int r;
4889     suppress_error = 0;
4890     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4891     if (r == -1)
4892       return -1;
4893   }
4894   {
4895     int r;
4896     suppress_error = 0;
4897     r = guestfs_mount (g, "/dev/sda1", "/");
4898     if (r == -1)
4899       return -1;
4900   }
4901   /* TestOutputFalse for is_file (1) */
4902   {
4903     int r;
4904     suppress_error = 0;
4905     r = guestfs_mkdir (g, "/new");
4906     if (r == -1)
4907       return -1;
4908   }
4909   {
4910     int r;
4911     suppress_error = 0;
4912     r = guestfs_is_file (g, "/new");
4913     if (r == -1)
4914       return -1;
4915     if (r) {
4916       fprintf (stderr, "test_is_file_1: expected false, got true\n");
4917       return -1;
4918     }
4919   }
4920   return 0;
4921 }
4922
4923 static int test_exists_0 (void)
4924 {
4925   /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
4926   {
4927     int r;
4928     suppress_error = 0;
4929     r = guestfs_umount_all (g);
4930     if (r == -1)
4931       return -1;
4932   }
4933   {
4934     int r;
4935     suppress_error = 0;
4936     r = guestfs_lvm_remove_all (g);
4937     if (r == -1)
4938       return -1;
4939   }
4940   {
4941     char *lines[] = {
4942       ",",
4943       NULL
4944     };
4945     int r;
4946     suppress_error = 0;
4947     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4948     if (r == -1)
4949       return -1;
4950   }
4951   {
4952     int r;
4953     suppress_error = 0;
4954     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4955     if (r == -1)
4956       return -1;
4957   }
4958   {
4959     int r;
4960     suppress_error = 0;
4961     r = guestfs_mount (g, "/dev/sda1", "/");
4962     if (r == -1)
4963       return -1;
4964   }
4965   /* TestOutputTrue for exists (0) */
4966   {
4967     int r;
4968     suppress_error = 0;
4969     r = guestfs_touch (g, "/new");
4970     if (r == -1)
4971       return -1;
4972   }
4973   {
4974     int r;
4975     suppress_error = 0;
4976     r = guestfs_exists (g, "/new");
4977     if (r == -1)
4978       return -1;
4979     if (!r) {
4980       fprintf (stderr, "test_exists_0: expected true, got false\n");
4981       return -1;
4982     }
4983   }
4984   return 0;
4985 }
4986
4987 static int test_exists_1 (void)
4988 {
4989   /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
4990   {
4991     int r;
4992     suppress_error = 0;
4993     r = guestfs_umount_all (g);
4994     if (r == -1)
4995       return -1;
4996   }
4997   {
4998     int r;
4999     suppress_error = 0;
5000     r = guestfs_lvm_remove_all (g);
5001     if (r == -1)
5002       return -1;
5003   }
5004   {
5005     char *lines[] = {
5006       ",",
5007       NULL
5008     };
5009     int r;
5010     suppress_error = 0;
5011     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5012     if (r == -1)
5013       return -1;
5014   }
5015   {
5016     int r;
5017     suppress_error = 0;
5018     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5019     if (r == -1)
5020       return -1;
5021   }
5022   {
5023     int r;
5024     suppress_error = 0;
5025     r = guestfs_mount (g, "/dev/sda1", "/");
5026     if (r == -1)
5027       return -1;
5028   }
5029   /* TestOutputTrue for exists (1) */
5030   {
5031     int r;
5032     suppress_error = 0;
5033     r = guestfs_mkdir (g, "/new");
5034     if (r == -1)
5035       return -1;
5036   }
5037   {
5038     int r;
5039     suppress_error = 0;
5040     r = guestfs_exists (g, "/new");
5041     if (r == -1)
5042       return -1;
5043     if (!r) {
5044       fprintf (stderr, "test_exists_1: expected true, got false\n");
5045       return -1;
5046     }
5047   }
5048   return 0;
5049 }
5050
5051 static int test_mkdir_p_0 (void)
5052 {
5053   /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
5054   {
5055     int r;
5056     suppress_error = 0;
5057     r = guestfs_umount_all (g);
5058     if (r == -1)
5059       return -1;
5060   }
5061   {
5062     int r;
5063     suppress_error = 0;
5064     r = guestfs_lvm_remove_all (g);
5065     if (r == -1)
5066       return -1;
5067   }
5068   {
5069     char *lines[] = {
5070       ",",
5071       NULL
5072     };
5073     int r;
5074     suppress_error = 0;
5075     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5076     if (r == -1)
5077       return -1;
5078   }
5079   {
5080     int r;
5081     suppress_error = 0;
5082     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5083     if (r == -1)
5084       return -1;
5085   }
5086   {
5087     int r;
5088     suppress_error = 0;
5089     r = guestfs_mount (g, "/dev/sda1", "/");
5090     if (r == -1)
5091       return -1;
5092   }
5093   /* TestOutputTrue for mkdir_p (0) */
5094   {
5095     int r;
5096     suppress_error = 0;
5097     r = guestfs_mkdir_p (g, "/new/foo/bar");
5098     if (r == -1)
5099       return -1;
5100   }
5101   {
5102     int r;
5103     suppress_error = 0;
5104     r = guestfs_is_dir (g, "/new/foo/bar");
5105     if (r == -1)
5106       return -1;
5107     if (!r) {
5108       fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
5109       return -1;
5110     }
5111   }
5112   return 0;
5113 }
5114
5115 static int test_mkdir_p_1 (void)
5116 {
5117   /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
5118   {
5119     int r;
5120     suppress_error = 0;
5121     r = guestfs_umount_all (g);
5122     if (r == -1)
5123       return -1;
5124   }
5125   {
5126     int r;
5127     suppress_error = 0;
5128     r = guestfs_lvm_remove_all (g);
5129     if (r == -1)
5130       return -1;
5131   }
5132   {
5133     char *lines[] = {
5134       ",",
5135       NULL
5136     };
5137     int r;
5138     suppress_error = 0;
5139     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5140     if (r == -1)
5141       return -1;
5142   }
5143   {
5144     int r;
5145     suppress_error = 0;
5146     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5147     if (r == -1)
5148       return -1;
5149   }
5150   {
5151     int r;
5152     suppress_error = 0;
5153     r = guestfs_mount (g, "/dev/sda1", "/");
5154     if (r == -1)
5155       return -1;
5156   }
5157   /* TestOutputTrue for mkdir_p (1) */
5158   {
5159     int r;
5160     suppress_error = 0;
5161     r = guestfs_mkdir_p (g, "/new/foo/bar");
5162     if (r == -1)
5163       return -1;
5164   }
5165   {
5166     int r;
5167     suppress_error = 0;
5168     r = guestfs_is_dir (g, "/new/foo");
5169     if (r == -1)
5170       return -1;
5171     if (!r) {
5172       fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
5173       return -1;
5174     }
5175   }
5176   return 0;
5177 }
5178
5179 static int test_mkdir_p_2 (void)
5180 {
5181   /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
5182   {
5183     int r;
5184     suppress_error = 0;
5185     r = guestfs_umount_all (g);
5186     if (r == -1)
5187       return -1;
5188   }
5189   {
5190     int r;
5191     suppress_error = 0;
5192     r = guestfs_lvm_remove_all (g);
5193     if (r == -1)
5194       return -1;
5195   }
5196   {
5197     char *lines[] = {
5198       ",",
5199       NULL
5200     };
5201     int r;
5202     suppress_error = 0;
5203     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5204     if (r == -1)
5205       return -1;
5206   }
5207   {
5208     int r;
5209     suppress_error = 0;
5210     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5211     if (r == -1)
5212       return -1;
5213   }
5214   {
5215     int r;
5216     suppress_error = 0;
5217     r = guestfs_mount (g, "/dev/sda1", "/");
5218     if (r == -1)
5219       return -1;
5220   }
5221   /* TestOutputTrue for mkdir_p (2) */
5222   {
5223     int r;
5224     suppress_error = 0;
5225     r = guestfs_mkdir_p (g, "/new/foo/bar");
5226     if (r == -1)
5227       return -1;
5228   }
5229   {
5230     int r;
5231     suppress_error = 0;
5232     r = guestfs_is_dir (g, "/new");
5233     if (r == -1)
5234       return -1;
5235     if (!r) {
5236       fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
5237       return -1;
5238     }
5239   }
5240   return 0;
5241 }
5242
5243 static int test_mkdir_0 (void)
5244 {
5245   /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
5246   {
5247     int r;
5248     suppress_error = 0;
5249     r = guestfs_umount_all (g);
5250     if (r == -1)
5251       return -1;
5252   }
5253   {
5254     int r;
5255     suppress_error = 0;
5256     r = guestfs_lvm_remove_all (g);
5257     if (r == -1)
5258       return -1;
5259   }
5260   {
5261     char *lines[] = {
5262       ",",
5263       NULL
5264     };
5265     int r;
5266     suppress_error = 0;
5267     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5268     if (r == -1)
5269       return -1;
5270   }
5271   {
5272     int r;
5273     suppress_error = 0;
5274     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5275     if (r == -1)
5276       return -1;
5277   }
5278   {
5279     int r;
5280     suppress_error = 0;
5281     r = guestfs_mount (g, "/dev/sda1", "/");
5282     if (r == -1)
5283       return -1;
5284   }
5285   /* TestOutputTrue for mkdir (0) */
5286   {
5287     int r;
5288     suppress_error = 0;
5289     r = guestfs_mkdir (g, "/new");
5290     if (r == -1)
5291       return -1;
5292   }
5293   {
5294     int r;
5295     suppress_error = 0;
5296     r = guestfs_is_dir (g, "/new");
5297     if (r == -1)
5298       return -1;
5299     if (!r) {
5300       fprintf (stderr, "test_mkdir_0: expected true, got false\n");
5301       return -1;
5302     }
5303   }
5304   return 0;
5305 }
5306
5307 static int test_mkdir_1 (void)
5308 {
5309   /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
5310   {
5311     int r;
5312     suppress_error = 0;
5313     r = guestfs_umount_all (g);
5314     if (r == -1)
5315       return -1;
5316   }
5317   {
5318     int r;
5319     suppress_error = 0;
5320     r = guestfs_lvm_remove_all (g);
5321     if (r == -1)
5322       return -1;
5323   }
5324   {
5325     char *lines[] = {
5326       ",",
5327       NULL
5328     };
5329     int r;
5330     suppress_error = 0;
5331     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5332     if (r == -1)
5333       return -1;
5334   }
5335   {
5336     int r;
5337     suppress_error = 0;
5338     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5339     if (r == -1)
5340       return -1;
5341   }
5342   {
5343     int r;
5344     suppress_error = 0;
5345     r = guestfs_mount (g, "/dev/sda1", "/");
5346     if (r == -1)
5347       return -1;
5348   }
5349   /* TestLastFail for mkdir (1) */
5350   {
5351     int r;
5352     suppress_error = 1;
5353     r = guestfs_mkdir (g, "/new/foo/bar");
5354     if (r != -1)
5355       return -1;
5356   }
5357   return 0;
5358 }
5359
5360 static int test_rm_rf_0 (void)
5361 {
5362   /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
5363   {
5364     int r;
5365     suppress_error = 0;
5366     r = guestfs_umount_all (g);
5367     if (r == -1)
5368       return -1;
5369   }
5370   {
5371     int r;
5372     suppress_error = 0;
5373     r = guestfs_lvm_remove_all (g);
5374     if (r == -1)
5375       return -1;
5376   }
5377   {
5378     char *lines[] = {
5379       ",",
5380       NULL
5381     };
5382     int r;
5383     suppress_error = 0;
5384     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5385     if (r == -1)
5386       return -1;
5387   }
5388   {
5389     int r;
5390     suppress_error = 0;
5391     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5392     if (r == -1)
5393       return -1;
5394   }
5395   {
5396     int r;
5397     suppress_error = 0;
5398     r = guestfs_mount (g, "/dev/sda1", "/");
5399     if (r == -1)
5400       return -1;
5401   }
5402   /* TestOutputFalse for rm_rf (0) */
5403   {
5404     int r;
5405     suppress_error = 0;
5406     r = guestfs_mkdir (g, "/new");
5407     if (r == -1)
5408       return -1;
5409   }
5410   {
5411     int r;
5412     suppress_error = 0;
5413     r = guestfs_mkdir (g, "/new/foo");
5414     if (r == -1)
5415       return -1;
5416   }
5417   {
5418     int r;
5419     suppress_error = 0;
5420     r = guestfs_touch (g, "/new/foo/bar");
5421     if (r == -1)
5422       return -1;
5423   }
5424   {
5425     int r;
5426     suppress_error = 0;
5427     r = guestfs_rm_rf (g, "/new");
5428     if (r == -1)
5429       return -1;
5430   }
5431   {
5432     int r;
5433     suppress_error = 0;
5434     r = guestfs_exists (g, "/new");
5435     if (r == -1)
5436       return -1;
5437     if (r) {
5438       fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
5439       return -1;
5440     }
5441   }
5442   return 0;
5443 }
5444
5445 static int test_rmdir_0 (void)
5446 {
5447   /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
5448   {
5449     int r;
5450     suppress_error = 0;
5451     r = guestfs_umount_all (g);
5452     if (r == -1)
5453       return -1;
5454   }
5455   {
5456     int r;
5457     suppress_error = 0;
5458     r = guestfs_lvm_remove_all (g);
5459     if (r == -1)
5460       return -1;
5461   }
5462   {
5463     char *lines[] = {
5464       ",",
5465       NULL
5466     };
5467     int r;
5468     suppress_error = 0;
5469     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5470     if (r == -1)
5471       return -1;
5472   }
5473   {
5474     int r;
5475     suppress_error = 0;
5476     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5477     if (r == -1)
5478       return -1;
5479   }
5480   {
5481     int r;
5482     suppress_error = 0;
5483     r = guestfs_mount (g, "/dev/sda1", "/");
5484     if (r == -1)
5485       return -1;
5486   }
5487   /* TestRun for rmdir (0) */
5488   {
5489     int r;
5490     suppress_error = 0;
5491     r = guestfs_mkdir (g, "/new");
5492     if (r == -1)
5493       return -1;
5494   }
5495   {
5496     int r;
5497     suppress_error = 0;
5498     r = guestfs_rmdir (g, "/new");
5499     if (r == -1)
5500       return -1;
5501   }
5502   return 0;
5503 }
5504
5505 static int test_rmdir_1 (void)
5506 {
5507   /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
5508   {
5509     int r;
5510     suppress_error = 0;
5511     r = guestfs_umount_all (g);
5512     if (r == -1)
5513       return -1;
5514   }
5515   {
5516     int r;
5517     suppress_error = 0;
5518     r = guestfs_lvm_remove_all (g);
5519     if (r == -1)
5520       return -1;
5521   }
5522   {
5523     char *lines[] = {
5524       ",",
5525       NULL
5526     };
5527     int r;
5528     suppress_error = 0;
5529     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5530     if (r == -1)
5531       return -1;
5532   }
5533   {
5534     int r;
5535     suppress_error = 0;
5536     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5537     if (r == -1)
5538       return -1;
5539   }
5540   {
5541     int r;
5542     suppress_error = 0;
5543     r = guestfs_mount (g, "/dev/sda1", "/");
5544     if (r == -1)
5545       return -1;
5546   }
5547   /* TestLastFail for rmdir (1) */
5548   {
5549     int r;
5550     suppress_error = 1;
5551     r = guestfs_rmdir (g, "/new");
5552     if (r != -1)
5553       return -1;
5554   }
5555   return 0;
5556 }
5557
5558 static int test_rmdir_2 (void)
5559 {
5560   /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
5561   {
5562     int r;
5563     suppress_error = 0;
5564     r = guestfs_umount_all (g);
5565     if (r == -1)
5566       return -1;
5567   }
5568   {
5569     int r;
5570     suppress_error = 0;
5571     r = guestfs_lvm_remove_all (g);
5572     if (r == -1)
5573       return -1;
5574   }
5575   {
5576     char *lines[] = {
5577       ",",
5578       NULL
5579     };
5580     int r;
5581     suppress_error = 0;
5582     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5583     if (r == -1)
5584       return -1;
5585   }
5586   {
5587     int r;
5588     suppress_error = 0;
5589     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5590     if (r == -1)
5591       return -1;
5592   }
5593   {
5594     int r;
5595     suppress_error = 0;
5596     r = guestfs_mount (g, "/dev/sda1", "/");
5597     if (r == -1)
5598       return -1;
5599   }
5600   /* TestLastFail for rmdir (2) */
5601   {
5602     int r;
5603     suppress_error = 0;
5604     r = guestfs_touch (g, "/new");
5605     if (r == -1)
5606       return -1;
5607   }
5608   {
5609     int r;
5610     suppress_error = 1;
5611     r = guestfs_rmdir (g, "/new");
5612     if (r != -1)
5613       return -1;
5614   }
5615   return 0;
5616 }
5617
5618 static int test_rm_0 (void)
5619 {
5620   /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
5621   {
5622     int r;
5623     suppress_error = 0;
5624     r = guestfs_umount_all (g);
5625     if (r == -1)
5626       return -1;
5627   }
5628   {
5629     int r;
5630     suppress_error = 0;
5631     r = guestfs_lvm_remove_all (g);
5632     if (r == -1)
5633       return -1;
5634   }
5635   {
5636     char *lines[] = {
5637       ",",
5638       NULL
5639     };
5640     int r;
5641     suppress_error = 0;
5642     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5643     if (r == -1)
5644       return -1;
5645   }
5646   {
5647     int r;
5648     suppress_error = 0;
5649     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5650     if (r == -1)
5651       return -1;
5652   }
5653   {
5654     int r;
5655     suppress_error = 0;
5656     r = guestfs_mount (g, "/dev/sda1", "/");
5657     if (r == -1)
5658       return -1;
5659   }
5660   /* TestRun for rm (0) */
5661   {
5662     int r;
5663     suppress_error = 0;
5664     r = guestfs_touch (g, "/new");
5665     if (r == -1)
5666       return -1;
5667   }
5668   {
5669     int r;
5670     suppress_error = 0;
5671     r = guestfs_rm (g, "/new");
5672     if (r == -1)
5673       return -1;
5674   }
5675   return 0;
5676 }
5677
5678 static int test_rm_1 (void)
5679 {
5680   /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
5681   {
5682     int r;
5683     suppress_error = 0;
5684     r = guestfs_umount_all (g);
5685     if (r == -1)
5686       return -1;
5687   }
5688   {
5689     int r;
5690     suppress_error = 0;
5691     r = guestfs_lvm_remove_all (g);
5692     if (r == -1)
5693       return -1;
5694   }
5695   {
5696     char *lines[] = {
5697       ",",
5698       NULL
5699     };
5700     int r;
5701     suppress_error = 0;
5702     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5703     if (r == -1)
5704       return -1;
5705   }
5706   {
5707     int r;
5708     suppress_error = 0;
5709     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5710     if (r == -1)
5711       return -1;
5712   }
5713   {
5714     int r;
5715     suppress_error = 0;
5716     r = guestfs_mount (g, "/dev/sda1", "/");
5717     if (r == -1)
5718       return -1;
5719   }
5720   /* TestLastFail for rm (1) */
5721   {
5722     int r;
5723     suppress_error = 1;
5724     r = guestfs_rm (g, "/new");
5725     if (r != -1)
5726       return -1;
5727   }
5728   return 0;
5729 }
5730
5731 static int test_rm_2 (void)
5732 {
5733   /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
5734   {
5735     int r;
5736     suppress_error = 0;
5737     r = guestfs_umount_all (g);
5738     if (r == -1)
5739       return -1;
5740   }
5741   {
5742     int r;
5743     suppress_error = 0;
5744     r = guestfs_lvm_remove_all (g);
5745     if (r == -1)
5746       return -1;
5747   }
5748   {
5749     char *lines[] = {
5750       ",",
5751       NULL
5752     };
5753     int r;
5754     suppress_error = 0;
5755     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5756     if (r == -1)
5757       return -1;
5758   }
5759   {
5760     int r;
5761     suppress_error = 0;
5762     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5763     if (r == -1)
5764       return -1;
5765   }
5766   {
5767     int r;
5768     suppress_error = 0;
5769     r = guestfs_mount (g, "/dev/sda1", "/");
5770     if (r == -1)
5771       return -1;
5772   }
5773   /* TestLastFail for rm (2) */
5774   {
5775     int r;
5776     suppress_error = 0;
5777     r = guestfs_mkdir (g, "/new");
5778     if (r == -1)
5779       return -1;
5780   }
5781   {
5782     int r;
5783     suppress_error = 1;
5784     r = guestfs_rm (g, "/new");
5785     if (r != -1)
5786       return -1;
5787   }
5788   return 0;
5789 }
5790
5791 static int test_read_lines_0 (void)
5792 {
5793   /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
5794   {
5795     int r;
5796     suppress_error = 0;
5797     r = guestfs_umount_all (g);
5798     if (r == -1)
5799       return -1;
5800   }
5801   {
5802     int r;
5803     suppress_error = 0;
5804     r = guestfs_lvm_remove_all (g);
5805     if (r == -1)
5806       return -1;
5807   }
5808   {
5809     char *lines[] = {
5810       ",",
5811       NULL
5812     };
5813     int r;
5814     suppress_error = 0;
5815     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5816     if (r == -1)
5817       return -1;
5818   }
5819   {
5820     int r;
5821     suppress_error = 0;
5822     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5823     if (r == -1)
5824       return -1;
5825   }
5826   {
5827     int r;
5828     suppress_error = 0;
5829     r = guestfs_mount (g, "/dev/sda1", "/");
5830     if (r == -1)
5831       return -1;
5832   }
5833   /* TestOutputList for read_lines (0) */
5834   {
5835     int r;
5836     suppress_error = 0;
5837     r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
5838     if (r == -1)
5839       return -1;
5840   }
5841   {
5842     char **r;
5843     int i;
5844     suppress_error = 0;
5845     r = guestfs_read_lines (g, "/new");
5846     if (r == NULL)
5847       return -1;
5848     if (!r[0]) {
5849       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5850       print_strings (r);
5851       return -1;
5852     }
5853     if (strcmp (r[0], "line1") != 0) {
5854       fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
5855       return -1;
5856     }
5857     if (!r[1]) {
5858       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5859       print_strings (r);
5860       return -1;
5861     }
5862     if (strcmp (r[1], "line2") != 0) {
5863       fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
5864       return -1;
5865     }
5866     if (!r[2]) {
5867       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5868       print_strings (r);
5869       return -1;
5870     }
5871     if (strcmp (r[2], "line3") != 0) {
5872       fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
5873       return -1;
5874     }
5875     if (r[3] != NULL) {
5876       fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
5877       print_strings (r);
5878       return -1;
5879     }
5880     for (i = 0; r[i] != NULL; ++i)
5881       free (r[i]);
5882     free (r);
5883   }
5884   return 0;
5885 }
5886
5887 static int test_read_lines_1 (void)
5888 {
5889   /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
5890   {
5891     int r;
5892     suppress_error = 0;
5893     r = guestfs_umount_all (g);
5894     if (r == -1)
5895       return -1;
5896   }
5897   {
5898     int r;
5899     suppress_error = 0;
5900     r = guestfs_lvm_remove_all (g);
5901     if (r == -1)
5902       return -1;
5903   }
5904   {
5905     char *lines[] = {
5906       ",",
5907       NULL
5908     };
5909     int r;
5910     suppress_error = 0;
5911     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5912     if (r == -1)
5913       return -1;
5914   }
5915   {
5916     int r;
5917     suppress_error = 0;
5918     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5919     if (r == -1)
5920       return -1;
5921   }
5922   {
5923     int r;
5924     suppress_error = 0;
5925     r = guestfs_mount (g, "/dev/sda1", "/");
5926     if (r == -1)
5927       return -1;
5928   }
5929   /* TestOutputList for read_lines (1) */
5930   {
5931     int r;
5932     suppress_error = 0;
5933     r = guestfs_write_file (g, "/new", "", 0);
5934     if (r == -1)
5935       return -1;
5936   }
5937   {
5938     char **r;
5939     int i;
5940     suppress_error = 0;
5941     r = guestfs_read_lines (g, "/new");
5942     if (r == NULL)
5943       return -1;
5944     if (r[0] != NULL) {
5945       fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
5946       print_strings (r);
5947       return -1;
5948     }
5949     for (i = 0; r[i] != NULL; ++i)
5950       free (r[i]);
5951     free (r);
5952   }
5953   return 0;
5954 }
5955
5956 static int test_lvs_0 (void)
5957 {
5958   /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
5959   {
5960     int r;
5961     suppress_error = 0;
5962     r = guestfs_umount_all (g);
5963     if (r == -1)
5964       return -1;
5965   }
5966   {
5967     int r;
5968     suppress_error = 0;
5969     r = guestfs_lvm_remove_all (g);
5970     if (r == -1)
5971       return -1;
5972   }
5973   {
5974     char *lines[] = {
5975       ",",
5976       NULL
5977     };
5978     int r;
5979     suppress_error = 0;
5980     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5981     if (r == -1)
5982       return -1;
5983   }
5984   {
5985     int r;
5986     suppress_error = 0;
5987     r = guestfs_pvcreate (g, "/dev/sda1");
5988     if (r == -1)
5989       return -1;
5990   }
5991   {
5992     char *physvols[] = {
5993       "/dev/sda1",
5994       NULL
5995     };
5996     int r;
5997     suppress_error = 0;
5998     r = guestfs_vgcreate (g, "VG", physvols);
5999     if (r == -1)
6000       return -1;
6001   }
6002   {
6003     int r;
6004     suppress_error = 0;
6005     r = guestfs_lvcreate (g, "LV", "VG", 8);
6006     if (r == -1)
6007       return -1;
6008   }
6009   {
6010     int r;
6011     suppress_error = 0;
6012     r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6013     if (r == -1)
6014       return -1;
6015   }
6016   {
6017     int r;
6018     suppress_error = 0;
6019     r = guestfs_mount (g, "/dev/VG/LV", "/");
6020     if (r == -1)
6021       return -1;
6022   }
6023   /* TestOutputList for lvs (0) */
6024   {
6025     char **r;
6026     int i;
6027     suppress_error = 0;
6028     r = guestfs_lvs (g);
6029     if (r == NULL)
6030       return -1;
6031     if (!r[0]) {
6032       fprintf (stderr, "test_lvs_0: short list returned from command\n");
6033       print_strings (r);
6034       return -1;
6035     }
6036     if (strcmp (r[0], "/dev/VG/LV") != 0) {
6037       fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
6038       return -1;
6039     }
6040     if (r[1] != NULL) {
6041       fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
6042       print_strings (r);
6043       return -1;
6044     }
6045     for (i = 0; r[i] != NULL; ++i)
6046       free (r[i]);
6047     free (r);
6048   }
6049   return 0;
6050 }
6051
6052 static int test_lvs_1 (void)
6053 {
6054   /* InitEmpty for lvs (1) */
6055   {
6056     int r;
6057     suppress_error = 0;
6058     r = guestfs_umount_all (g);
6059     if (r == -1)
6060       return -1;
6061   }
6062   {
6063     int r;
6064     suppress_error = 0;
6065     r = guestfs_lvm_remove_all (g);
6066     if (r == -1)
6067       return -1;
6068   }
6069   /* TestOutputList for lvs (1) */
6070   {
6071     char *lines[] = {
6072       ",10",
6073       ",20",
6074       ",",
6075       NULL
6076     };
6077     int r;
6078     suppress_error = 0;
6079     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6080     if (r == -1)
6081       return -1;
6082   }
6083   {
6084     int r;
6085     suppress_error = 0;
6086     r = guestfs_pvcreate (g, "/dev/sda1");
6087     if (r == -1)
6088       return -1;
6089   }
6090   {
6091     int r;
6092     suppress_error = 0;
6093     r = guestfs_pvcreate (g, "/dev/sda2");
6094     if (r == -1)
6095       return -1;
6096   }
6097   {
6098     int r;
6099     suppress_error = 0;
6100     r = guestfs_pvcreate (g, "/dev/sda3");
6101     if (r == -1)
6102       return -1;
6103   }
6104   {
6105     char *physvols[] = {
6106       "/dev/sda1",
6107       "/dev/sda2",
6108       NULL
6109     };
6110     int r;
6111     suppress_error = 0;
6112     r = guestfs_vgcreate (g, "VG1", physvols);
6113     if (r == -1)
6114       return -1;
6115   }
6116   {
6117     char *physvols[] = {
6118       "/dev/sda3",
6119       NULL
6120     };
6121     int r;
6122     suppress_error = 0;
6123     r = guestfs_vgcreate (g, "VG2", physvols);
6124     if (r == -1)
6125       return -1;
6126   }
6127   {
6128     int r;
6129     suppress_error = 0;
6130     r = guestfs_lvcreate (g, "LV1", "VG1", 50);
6131     if (r == -1)
6132       return -1;
6133   }
6134   {
6135     int r;
6136     suppress_error = 0;
6137     r = guestfs_lvcreate (g, "LV2", "VG1", 50);
6138     if (r == -1)
6139       return -1;
6140   }
6141   {
6142     int r;
6143     suppress_error = 0;
6144     r = guestfs_lvcreate (g, "LV3", "VG2", 50);
6145     if (r == -1)
6146       return -1;
6147   }
6148   {
6149     char **r;
6150     int i;
6151     suppress_error = 0;
6152     r = guestfs_lvs (g);
6153     if (r == NULL)
6154       return -1;
6155     if (!r[0]) {
6156       fprintf (stderr, "test_lvs_1: short list returned from command\n");
6157       print_strings (r);
6158       return -1;
6159     }
6160     if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
6161       fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
6162       return -1;
6163     }
6164     if (!r[1]) {
6165       fprintf (stderr, "test_lvs_1: short list returned from command\n");
6166       print_strings (r);
6167       return -1;
6168     }
6169     if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
6170       fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
6171       return -1;
6172     }
6173     if (!r[2]) {
6174       fprintf (stderr, "test_lvs_1: short list returned from command\n");
6175       print_strings (r);
6176       return -1;
6177     }
6178     if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
6179       fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
6180       return -1;
6181     }
6182     if (r[3] != NULL) {
6183       fprintf (stderr, "test_lvs_1: 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_vgs_0 (void)
6195 {
6196   /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
6197   {
6198     int r;
6199     suppress_error = 0;
6200     r = guestfs_umount_all (g);
6201     if (r == -1)
6202       return -1;
6203   }
6204   {
6205     int r;
6206     suppress_error = 0;
6207     r = guestfs_lvm_remove_all (g);
6208     if (r == -1)
6209       return -1;
6210   }
6211   {
6212     char *lines[] = {
6213       ",",
6214       NULL
6215     };
6216     int r;
6217     suppress_error = 0;
6218     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6219     if (r == -1)
6220       return -1;
6221   }
6222   {
6223     int r;
6224     suppress_error = 0;
6225     r = guestfs_pvcreate (g, "/dev/sda1");
6226     if (r == -1)
6227       return -1;
6228   }
6229   {
6230     char *physvols[] = {
6231       "/dev/sda1",
6232       NULL
6233     };
6234     int r;
6235     suppress_error = 0;
6236     r = guestfs_vgcreate (g, "VG", physvols);
6237     if (r == -1)
6238       return -1;
6239   }
6240   {
6241     int r;
6242     suppress_error = 0;
6243     r = guestfs_lvcreate (g, "LV", "VG", 8);
6244     if (r == -1)
6245       return -1;
6246   }
6247   {
6248     int r;
6249     suppress_error = 0;
6250     r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6251     if (r == -1)
6252       return -1;
6253   }
6254   {
6255     int r;
6256     suppress_error = 0;
6257     r = guestfs_mount (g, "/dev/VG/LV", "/");
6258     if (r == -1)
6259       return -1;
6260   }
6261   /* TestOutputList for vgs (0) */
6262   {
6263     char **r;
6264     int i;
6265     suppress_error = 0;
6266     r = guestfs_vgs (g);
6267     if (r == NULL)
6268       return -1;
6269     if (!r[0]) {
6270       fprintf (stderr, "test_vgs_0: short list returned from command\n");
6271       print_strings (r);
6272       return -1;
6273     }
6274     if (strcmp (r[0], "VG") != 0) {
6275       fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
6276       return -1;
6277     }
6278     if (r[1] != NULL) {
6279       fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
6280       print_strings (r);
6281       return -1;
6282     }
6283     for (i = 0; r[i] != NULL; ++i)
6284       free (r[i]);
6285     free (r);
6286   }
6287   return 0;
6288 }
6289
6290 static int test_vgs_1 (void)
6291 {
6292   /* InitEmpty for vgs (1) */
6293   {
6294     int r;
6295     suppress_error = 0;
6296     r = guestfs_umount_all (g);
6297     if (r == -1)
6298       return -1;
6299   }
6300   {
6301     int r;
6302     suppress_error = 0;
6303     r = guestfs_lvm_remove_all (g);
6304     if (r == -1)
6305       return -1;
6306   }
6307   /* TestOutputList for vgs (1) */
6308   {
6309     char *lines[] = {
6310       ",10",
6311       ",20",
6312       ",",
6313       NULL
6314     };
6315     int r;
6316     suppress_error = 0;
6317     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6318     if (r == -1)
6319       return -1;
6320   }
6321   {
6322     int r;
6323     suppress_error = 0;
6324     r = guestfs_pvcreate (g, "/dev/sda1");
6325     if (r == -1)
6326       return -1;
6327   }
6328   {
6329     int r;
6330     suppress_error = 0;
6331     r = guestfs_pvcreate (g, "/dev/sda2");
6332     if (r == -1)
6333       return -1;
6334   }
6335   {
6336     int r;
6337     suppress_error = 0;
6338     r = guestfs_pvcreate (g, "/dev/sda3");
6339     if (r == -1)
6340       return -1;
6341   }
6342   {
6343     char *physvols[] = {
6344       "/dev/sda1",
6345       "/dev/sda2",
6346       NULL
6347     };
6348     int r;
6349     suppress_error = 0;
6350     r = guestfs_vgcreate (g, "VG1", physvols);
6351     if (r == -1)
6352       return -1;
6353   }
6354   {
6355     char *physvols[] = {
6356       "/dev/sda3",
6357       NULL
6358     };
6359     int r;
6360     suppress_error = 0;
6361     r = guestfs_vgcreate (g, "VG2", physvols);
6362     if (r == -1)
6363       return -1;
6364   }
6365   {
6366     char **r;
6367     int i;
6368     suppress_error = 0;
6369     r = guestfs_vgs (g);
6370     if (r == NULL)
6371       return -1;
6372     if (!r[0]) {
6373       fprintf (stderr, "test_vgs_1: short list returned from command\n");
6374       print_strings (r);
6375       return -1;
6376     }
6377     if (strcmp (r[0], "VG1") != 0) {
6378       fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
6379       return -1;
6380     }
6381     if (!r[1]) {
6382       fprintf (stderr, "test_vgs_1: short list returned from command\n");
6383       print_strings (r);
6384       return -1;
6385     }
6386     if (strcmp (r[1], "VG2") != 0) {
6387       fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
6388       return -1;
6389     }
6390     if (r[2] != NULL) {
6391       fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
6392       print_strings (r);
6393       return -1;
6394     }
6395     for (i = 0; r[i] != NULL; ++i)
6396       free (r[i]);
6397     free (r);
6398   }
6399   return 0;
6400 }
6401
6402 static int test_pvs_0 (void)
6403 {
6404   /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
6405   {
6406     int r;
6407     suppress_error = 0;
6408     r = guestfs_umount_all (g);
6409     if (r == -1)
6410       return -1;
6411   }
6412   {
6413     int r;
6414     suppress_error = 0;
6415     r = guestfs_lvm_remove_all (g);
6416     if (r == -1)
6417       return -1;
6418   }
6419   {
6420     char *lines[] = {
6421       ",",
6422       NULL
6423     };
6424     int r;
6425     suppress_error = 0;
6426     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6427     if (r == -1)
6428       return -1;
6429   }
6430   {
6431     int r;
6432     suppress_error = 0;
6433     r = guestfs_pvcreate (g, "/dev/sda1");
6434     if (r == -1)
6435       return -1;
6436   }
6437   {
6438     char *physvols[] = {
6439       "/dev/sda1",
6440       NULL
6441     };
6442     int r;
6443     suppress_error = 0;
6444     r = guestfs_vgcreate (g, "VG", physvols);
6445     if (r == -1)
6446       return -1;
6447   }
6448   {
6449     int r;
6450     suppress_error = 0;
6451     r = guestfs_lvcreate (g, "LV", "VG", 8);
6452     if (r == -1)
6453       return -1;
6454   }
6455   {
6456     int r;
6457     suppress_error = 0;
6458     r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6459     if (r == -1)
6460       return -1;
6461   }
6462   {
6463     int r;
6464     suppress_error = 0;
6465     r = guestfs_mount (g, "/dev/VG/LV", "/");
6466     if (r == -1)
6467       return -1;
6468   }
6469   /* TestOutputList for pvs (0) */
6470   {
6471     char **r;
6472     int i;
6473     suppress_error = 0;
6474     r = guestfs_pvs (g);
6475     if (r == NULL)
6476       return -1;
6477     if (!r[0]) {
6478       fprintf (stderr, "test_pvs_0: short list returned from command\n");
6479       print_strings (r);
6480       return -1;
6481     }
6482     if (strcmp (r[0], "/dev/sda1") != 0) {
6483       fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6484       return -1;
6485     }
6486     if (r[1] != NULL) {
6487       fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
6488       print_strings (r);
6489       return -1;
6490     }
6491     for (i = 0; r[i] != NULL; ++i)
6492       free (r[i]);
6493     free (r);
6494   }
6495   return 0;
6496 }
6497
6498 static int test_pvs_1 (void)
6499 {
6500   /* InitEmpty for pvs (1) */
6501   {
6502     int r;
6503     suppress_error = 0;
6504     r = guestfs_umount_all (g);
6505     if (r == -1)
6506       return -1;
6507   }
6508   {
6509     int r;
6510     suppress_error = 0;
6511     r = guestfs_lvm_remove_all (g);
6512     if (r == -1)
6513       return -1;
6514   }
6515   /* TestOutputList for pvs (1) */
6516   {
6517     char *lines[] = {
6518       ",10",
6519       ",20",
6520       ",",
6521       NULL
6522     };
6523     int r;
6524     suppress_error = 0;
6525     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6526     if (r == -1)
6527       return -1;
6528   }
6529   {
6530     int r;
6531     suppress_error = 0;
6532     r = guestfs_pvcreate (g, "/dev/sda1");
6533     if (r == -1)
6534       return -1;
6535   }
6536   {
6537     int r;
6538     suppress_error = 0;
6539     r = guestfs_pvcreate (g, "/dev/sda2");
6540     if (r == -1)
6541       return -1;
6542   }
6543   {
6544     int r;
6545     suppress_error = 0;
6546     r = guestfs_pvcreate (g, "/dev/sda3");
6547     if (r == -1)
6548       return -1;
6549   }
6550   {
6551     char **r;
6552     int i;
6553     suppress_error = 0;
6554     r = guestfs_pvs (g);
6555     if (r == NULL)
6556       return -1;
6557     if (!r[0]) {
6558       fprintf (stderr, "test_pvs_1: short list returned from command\n");
6559       print_strings (r);
6560       return -1;
6561     }
6562     if (strcmp (r[0], "/dev/sda1") != 0) {
6563       fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6564       return -1;
6565     }
6566     if (!r[1]) {
6567       fprintf (stderr, "test_pvs_1: short list returned from command\n");
6568       print_strings (r);
6569       return -1;
6570     }
6571     if (strcmp (r[1], "/dev/sda2") != 0) {
6572       fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6573       return -1;
6574     }
6575     if (!r[2]) {
6576       fprintf (stderr, "test_pvs_1: short list returned from command\n");
6577       print_strings (r);
6578       return -1;
6579     }
6580     if (strcmp (r[2], "/dev/sda3") != 0) {
6581       fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6582       return -1;
6583     }
6584     if (r[3] != NULL) {
6585       fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
6586       print_strings (r);
6587       return -1;
6588     }
6589     for (i = 0; r[i] != NULL; ++i)
6590       free (r[i]);
6591     free (r);
6592   }
6593   return 0;
6594 }
6595
6596 static int test_list_partitions_0 (void)
6597 {
6598   /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
6599   {
6600     int r;
6601     suppress_error = 0;
6602     r = guestfs_umount_all (g);
6603     if (r == -1)
6604       return -1;
6605   }
6606   {
6607     int r;
6608     suppress_error = 0;
6609     r = guestfs_lvm_remove_all (g);
6610     if (r == -1)
6611       return -1;
6612   }
6613   {
6614     char *lines[] = {
6615       ",",
6616       NULL
6617     };
6618     int r;
6619     suppress_error = 0;
6620     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6621     if (r == -1)
6622       return -1;
6623   }
6624   {
6625     int r;
6626     suppress_error = 0;
6627     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6628     if (r == -1)
6629       return -1;
6630   }
6631   {
6632     int r;
6633     suppress_error = 0;
6634     r = guestfs_mount (g, "/dev/sda1", "/");
6635     if (r == -1)
6636       return -1;
6637   }
6638   /* TestOutputList for list_partitions (0) */
6639   {
6640     char **r;
6641     int i;
6642     suppress_error = 0;
6643     r = guestfs_list_partitions (g);
6644     if (r == NULL)
6645       return -1;
6646     if (!r[0]) {
6647       fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
6648       print_strings (r);
6649       return -1;
6650     }
6651     if (strcmp (r[0], "/dev/sda1") != 0) {
6652       fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6653       return -1;
6654     }
6655     if (r[1] != NULL) {
6656       fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
6657       print_strings (r);
6658       return -1;
6659     }
6660     for (i = 0; r[i] != NULL; ++i)
6661       free (r[i]);
6662     free (r);
6663   }
6664   return 0;
6665 }
6666
6667 static int test_list_partitions_1 (void)
6668 {
6669   /* InitEmpty for list_partitions (1) */
6670   {
6671     int r;
6672     suppress_error = 0;
6673     r = guestfs_umount_all (g);
6674     if (r == -1)
6675       return -1;
6676   }
6677   {
6678     int r;
6679     suppress_error = 0;
6680     r = guestfs_lvm_remove_all (g);
6681     if (r == -1)
6682       return -1;
6683   }
6684   /* TestOutputList for list_partitions (1) */
6685   {
6686     char *lines[] = {
6687       ",10",
6688       ",20",
6689       ",",
6690       NULL
6691     };
6692     int r;
6693     suppress_error = 0;
6694     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6695     if (r == -1)
6696       return -1;
6697   }
6698   {
6699     char **r;
6700     int i;
6701     suppress_error = 0;
6702     r = guestfs_list_partitions (g);
6703     if (r == NULL)
6704       return -1;
6705     if (!r[0]) {
6706       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6707       print_strings (r);
6708       return -1;
6709     }
6710     if (strcmp (r[0], "/dev/sda1") != 0) {
6711       fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6712       return -1;
6713     }
6714     if (!r[1]) {
6715       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6716       print_strings (r);
6717       return -1;
6718     }
6719     if (strcmp (r[1], "/dev/sda2") != 0) {
6720       fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6721       return -1;
6722     }
6723     if (!r[2]) {
6724       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6725       print_strings (r);
6726       return -1;
6727     }
6728     if (strcmp (r[2], "/dev/sda3") != 0) {
6729       fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6730       return -1;
6731     }
6732     if (r[3] != NULL) {
6733       fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
6734       print_strings (r);
6735       return -1;
6736     }
6737     for (i = 0; r[i] != NULL; ++i)
6738       free (r[i]);
6739     free (r);
6740   }
6741   return 0;
6742 }
6743
6744 static int test_list_devices_0 (void)
6745 {
6746   /* InitEmpty for list_devices (0) */
6747   {
6748     int r;
6749     suppress_error = 0;
6750     r = guestfs_umount_all (g);
6751     if (r == -1)
6752       return -1;
6753   }
6754   {
6755     int r;
6756     suppress_error = 0;
6757     r = guestfs_lvm_remove_all (g);
6758     if (r == -1)
6759       return -1;
6760   }
6761   /* TestOutputList for list_devices (0) */
6762   {
6763     char **r;
6764     int i;
6765     suppress_error = 0;
6766     r = guestfs_list_devices (g);
6767     if (r == NULL)
6768       return -1;
6769     if (!r[0]) {
6770       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6771       print_strings (r);
6772       return -1;
6773     }
6774     if (strcmp (r[0], "/dev/sda") != 0) {
6775       fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
6776       return -1;
6777     }
6778     if (!r[1]) {
6779       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6780       print_strings (r);
6781       return -1;
6782     }
6783     if (strcmp (r[1], "/dev/sdb") != 0) {
6784       fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
6785       return -1;
6786     }
6787     if (!r[2]) {
6788       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6789       print_strings (r);
6790       return -1;
6791     }
6792     if (strcmp (r[2], "/dev/sdc") != 0) {
6793       fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
6794       return -1;
6795     }
6796     if (r[3] != NULL) {
6797       fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
6798       print_strings (r);
6799       return -1;
6800     }
6801     for (i = 0; r[i] != NULL; ++i)
6802       free (r[i]);
6803     free (r);
6804   }
6805   return 0;
6806 }
6807
6808 static int test_ls_0 (void)
6809 {
6810   /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
6811   {
6812     int r;
6813     suppress_error = 0;
6814     r = guestfs_umount_all (g);
6815     if (r == -1)
6816       return -1;
6817   }
6818   {
6819     int r;
6820     suppress_error = 0;
6821     r = guestfs_lvm_remove_all (g);
6822     if (r == -1)
6823       return -1;
6824   }
6825   {
6826     char *lines[] = {
6827       ",",
6828       NULL
6829     };
6830     int r;
6831     suppress_error = 0;
6832     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6833     if (r == -1)
6834       return -1;
6835   }
6836   {
6837     int r;
6838     suppress_error = 0;
6839     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6840     if (r == -1)
6841       return -1;
6842   }
6843   {
6844     int r;
6845     suppress_error = 0;
6846     r = guestfs_mount (g, "/dev/sda1", "/");
6847     if (r == -1)
6848       return -1;
6849   }
6850   /* TestOutputList for ls (0) */
6851   {
6852     int r;
6853     suppress_error = 0;
6854     r = guestfs_touch (g, "/new");
6855     if (r == -1)
6856       return -1;
6857   }
6858   {
6859     int r;
6860     suppress_error = 0;
6861     r = guestfs_touch (g, "/newer");
6862     if (r == -1)
6863       return -1;
6864   }
6865   {
6866     int r;
6867     suppress_error = 0;
6868     r = guestfs_touch (g, "/newest");
6869     if (r == -1)
6870       return -1;
6871   }
6872   {
6873     char **r;
6874     int i;
6875     suppress_error = 0;
6876     r = guestfs_ls (g, "/");
6877     if (r == NULL)
6878       return -1;
6879     if (!r[0]) {
6880       fprintf (stderr, "test_ls_0: short list returned from command\n");
6881       print_strings (r);
6882       return -1;
6883     }
6884     if (strcmp (r[0], "lost+found") != 0) {
6885       fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
6886       return -1;
6887     }
6888     if (!r[1]) {
6889       fprintf (stderr, "test_ls_0: short list returned from command\n");
6890       print_strings (r);
6891       return -1;
6892     }
6893     if (strcmp (r[1], "new") != 0) {
6894       fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
6895       return -1;
6896     }
6897     if (!r[2]) {
6898       fprintf (stderr, "test_ls_0: short list returned from command\n");
6899       print_strings (r);
6900       return -1;
6901     }
6902     if (strcmp (r[2], "newer") != 0) {
6903       fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
6904       return -1;
6905     }
6906     if (!r[3]) {
6907       fprintf (stderr, "test_ls_0: short list returned from command\n");
6908       print_strings (r);
6909       return -1;
6910     }
6911     if (strcmp (r[3], "newest") != 0) {
6912       fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
6913       return -1;
6914     }
6915     if (r[4] != NULL) {
6916       fprintf (stderr, "test_ls_0: extra elements returned from command\n");
6917       print_strings (r);
6918       return -1;
6919     }
6920     for (i = 0; r[i] != NULL; ++i)
6921       free (r[i]);
6922     free (r);
6923   }
6924   return 0;
6925 }
6926
6927 static int test_cat_0 (void)
6928 {
6929   /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
6930   {
6931     int r;
6932     suppress_error = 0;
6933     r = guestfs_umount_all (g);
6934     if (r == -1)
6935       return -1;
6936   }
6937   {
6938     int r;
6939     suppress_error = 0;
6940     r = guestfs_lvm_remove_all (g);
6941     if (r == -1)
6942       return -1;
6943   }
6944   {
6945     char *lines[] = {
6946       ",",
6947       NULL
6948     };
6949     int r;
6950     suppress_error = 0;
6951     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6952     if (r == -1)
6953       return -1;
6954   }
6955   {
6956     int r;
6957     suppress_error = 0;
6958     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6959     if (r == -1)
6960       return -1;
6961   }
6962   {
6963     int r;
6964     suppress_error = 0;
6965     r = guestfs_mount (g, "/dev/sda1", "/");
6966     if (r == -1)
6967       return -1;
6968   }
6969   /* TestOutput for cat (0) */
6970   {
6971     int r;
6972     suppress_error = 0;
6973     r = guestfs_write_file (g, "/new", "new file contents", 0);
6974     if (r == -1)
6975       return -1;
6976   }
6977   {
6978     char *r;
6979     suppress_error = 0;
6980     r = guestfs_cat (g, "/new");
6981     if (r == NULL)
6982       return -1;
6983     if (strcmp (r, "new file contents") != 0) {
6984       fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
6985       return -1;
6986     }
6987     free (r);
6988   }
6989   return 0;
6990 }
6991
6992 static int test_touch_0 (void)
6993 {
6994   /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
6995   {
6996     int r;
6997     suppress_error = 0;
6998     r = guestfs_umount_all (g);
6999     if (r == -1)
7000       return -1;
7001   }
7002   {
7003     int r;
7004     suppress_error = 0;
7005     r = guestfs_lvm_remove_all (g);
7006     if (r == -1)
7007       return -1;
7008   }
7009   {
7010     char *lines[] = {
7011       ",",
7012       NULL
7013     };
7014     int r;
7015     suppress_error = 0;
7016     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
7017     if (r == -1)
7018       return -1;
7019   }
7020   {
7021     int r;
7022     suppress_error = 0;
7023     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
7024     if (r == -1)
7025       return -1;
7026   }
7027   {
7028     int r;
7029     suppress_error = 0;
7030     r = guestfs_mount (g, "/dev/sda1", "/");
7031     if (r == -1)
7032       return -1;
7033   }
7034   /* TestOutputTrue for touch (0) */
7035   {
7036     int r;
7037     suppress_error = 0;
7038     r = guestfs_touch (g, "/new");
7039     if (r == -1)
7040       return -1;
7041   }
7042   {
7043     int r;
7044     suppress_error = 0;
7045     r = guestfs_exists (g, "/new");
7046     if (r == -1)
7047       return -1;
7048     if (!r) {
7049       fprintf (stderr, "test_touch_0: expected true, got false\n");
7050       return -1;
7051     }
7052   }
7053   return 0;
7054 }
7055
7056 static int test_sync_0 (void)
7057 {
7058   /* InitEmpty for sync (0) */
7059   {
7060     int r;
7061     suppress_error = 0;
7062     r = guestfs_umount_all (g);
7063     if (r == -1)
7064       return -1;
7065   }
7066   {
7067     int r;
7068     suppress_error = 0;
7069     r = guestfs_lvm_remove_all (g);
7070     if (r == -1)
7071       return -1;
7072   }
7073   /* TestRun for sync (0) */
7074   {
7075     int r;
7076     suppress_error = 0;
7077     r = guestfs_sync (g);
7078     if (r == -1)
7079       return -1;
7080   }
7081   return 0;
7082 }
7083
7084 static int test_mount_0 (void)
7085 {
7086   /* InitEmpty for mount (0) */
7087   {
7088     int r;
7089     suppress_error = 0;
7090     r = guestfs_umount_all (g);
7091     if (r == -1)
7092       return -1;
7093   }
7094   {
7095     int r;
7096     suppress_error = 0;
7097     r = guestfs_lvm_remove_all (g);
7098     if (r == -1)
7099       return -1;
7100   }
7101   /* TestOutput for mount (0) */
7102   {
7103     char *lines[] = {
7104       ",",
7105       NULL
7106     };
7107     int r;
7108     suppress_error = 0;
7109     r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
7110     if (r == -1)
7111       return -1;
7112   }
7113   {
7114     int r;
7115     suppress_error = 0;
7116     r = guestfs_mkfs (g, "ext2", "/dev/sda1");
7117     if (r == -1)
7118       return -1;
7119   }
7120   {
7121     int r;
7122     suppress_error = 0;
7123     r = guestfs_mount (g, "/dev/sda1", "/");
7124     if (r == -1)
7125       return -1;
7126   }
7127   {
7128     int r;
7129     suppress_error = 0;
7130     r = guestfs_write_file (g, "/new", "new file contents", 0);
7131     if (r == -1)
7132       return -1;
7133   }
7134   {
7135     char *r;
7136     suppress_error = 0;
7137     r = guestfs_cat (g, "/new");
7138     if (r == NULL)
7139       return -1;
7140     if (strcmp (r, "new file contents") != 0) {
7141       fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
7142       return -1;
7143     }
7144     free (r);
7145   }
7146   return 0;
7147 }
7148
7149 int main (int argc, char *argv[])
7150 {
7151   char c = 0;
7152   int failed = 0;
7153   const char *srcdir;
7154   const char *filename;
7155   int fd;
7156   int nr_tests, test_num = 0;
7157
7158   no_test_warnings ();
7159
7160   g = guestfs_create ();
7161   if (g == NULL) {
7162     printf ("guestfs_create FAILED\n");
7163     exit (1);
7164   }
7165
7166   guestfs_set_error_handler (g, print_error, NULL);
7167
7168   srcdir = getenv ("srcdir");
7169   if (!srcdir) srcdir = ".";
7170   chdir (srcdir);
7171   guestfs_set_path (g, ".");
7172
7173   filename = "test1.img";
7174   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7175   if (fd == -1) {
7176     perror (filename);
7177     exit (1);
7178   }
7179   if (lseek (fd, 524288000, SEEK_SET) == -1) {
7180     perror ("lseek");
7181     close (fd);
7182     unlink (filename);
7183     exit (1);
7184   }
7185   if (write (fd, &c, 1) == -1) {
7186     perror ("write");
7187     close (fd);
7188     unlink (filename);
7189     exit (1);
7190   }
7191   if (close (fd) == -1) {
7192     perror (filename);
7193     unlink (filename);
7194     exit (1);
7195   }
7196   if (guestfs_add_drive (g, filename) == -1) {
7197     printf ("guestfs_add_drive %s FAILED\n", filename);
7198     exit (1);
7199   }
7200
7201   filename = "test2.img";
7202   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7203   if (fd == -1) {
7204     perror (filename);
7205     exit (1);
7206   }
7207   if (lseek (fd, 52428800, SEEK_SET) == -1) {
7208     perror ("lseek");
7209     close (fd);
7210     unlink (filename);
7211     exit (1);
7212   }
7213   if (write (fd, &c, 1) == -1) {
7214     perror ("write");
7215     close (fd);
7216     unlink (filename);
7217     exit (1);
7218   }
7219   if (close (fd) == -1) {
7220     perror (filename);
7221     unlink (filename);
7222     exit (1);
7223   }
7224   if (guestfs_add_drive (g, filename) == -1) {
7225     printf ("guestfs_add_drive %s FAILED\n", filename);
7226     exit (1);
7227   }
7228
7229   filename = "test3.img";
7230   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7231   if (fd == -1) {
7232     perror (filename);
7233     exit (1);
7234   }
7235   if (lseek (fd, 10485760, SEEK_SET) == -1) {
7236     perror ("lseek");
7237     close (fd);
7238     unlink (filename);
7239     exit (1);
7240   }
7241   if (write (fd, &c, 1) == -1) {
7242     perror ("write");
7243     close (fd);
7244     unlink (filename);
7245     exit (1);
7246   }
7247   if (close (fd) == -1) {
7248     perror (filename);
7249     unlink (filename);
7250     exit (1);
7251   }
7252   if (guestfs_add_drive (g, filename) == -1) {
7253     printf ("guestfs_add_drive %s FAILED\n", filename);
7254     exit (1);
7255   }
7256
7257   if (guestfs_launch (g) == -1) {
7258     printf ("guestfs_launch FAILED\n");
7259     exit (1);
7260   }
7261   if (guestfs_wait_ready (g) == -1) {
7262     printf ("guestfs_wait_ready FAILED\n");
7263     exit (1);
7264   }
7265
7266   nr_tests = 102;
7267
7268   test_num++;
7269   printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
7270   if (test_drop_caches_0 () == -1) {
7271     printf ("test_drop_caches_0 FAILED\n");
7272     failed++;
7273   }
7274   test_num++;
7275   printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
7276   if (test_mv_0 () == -1) {
7277     printf ("test_mv_0 FAILED\n");
7278     failed++;
7279   }
7280   test_num++;
7281   printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
7282   if (test_mv_1 () == -1) {
7283     printf ("test_mv_1 FAILED\n");
7284     failed++;
7285   }
7286   test_num++;
7287   printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
7288   if (test_cp_a_0 () == -1) {
7289     printf ("test_cp_a_0 FAILED\n");
7290     failed++;
7291   }
7292   test_num++;
7293   printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
7294   if (test_cp_0 () == -1) {
7295     printf ("test_cp_0 FAILED\n");
7296     failed++;
7297   }
7298   test_num++;
7299   printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
7300   if (test_cp_1 () == -1) {
7301     printf ("test_cp_1 FAILED\n");
7302     failed++;
7303   }
7304   test_num++;
7305   printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
7306   if (test_cp_2 () == -1) {
7307     printf ("test_cp_2 FAILED\n");
7308     failed++;
7309   }
7310   test_num++;
7311   printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
7312   if (test_grub_install_0 () == -1) {
7313     printf ("test_grub_install_0 FAILED\n");
7314     failed++;
7315   }
7316   test_num++;
7317   printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
7318   if (test_zero_0 () == -1) {
7319     printf ("test_zero_0 FAILED\n");
7320     failed++;
7321   }
7322   test_num++;
7323   printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
7324   if (test_fsck_0 () == -1) {
7325     printf ("test_fsck_0 FAILED\n");
7326     failed++;
7327   }
7328   test_num++;
7329   printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
7330   if (test_fsck_1 () == -1) {
7331     printf ("test_fsck_1 FAILED\n");
7332     failed++;
7333   }
7334   test_num++;
7335   printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
7336   if (test_set_e2uuid_0 () == -1) {
7337     printf ("test_set_e2uuid_0 FAILED\n");
7338     failed++;
7339   }
7340   test_num++;
7341   printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
7342   if (test_set_e2uuid_1 () == -1) {
7343     printf ("test_set_e2uuid_1 FAILED\n");
7344     failed++;
7345   }
7346   test_num++;
7347   printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
7348   if (test_set_e2uuid_2 () == -1) {
7349     printf ("test_set_e2uuid_2 FAILED\n");
7350     failed++;
7351   }
7352   test_num++;
7353   printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
7354   if (test_set_e2uuid_3 () == -1) {
7355     printf ("test_set_e2uuid_3 FAILED\n");
7356     failed++;
7357   }
7358   test_num++;
7359   printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
7360   if (test_set_e2label_0 () == -1) {
7361     printf ("test_set_e2label_0 FAILED\n");
7362     failed++;
7363   }
7364   test_num++;
7365   printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
7366   if (test_pvremove_0 () == -1) {
7367     printf ("test_pvremove_0 FAILED\n");
7368     failed++;
7369   }
7370   test_num++;
7371   printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
7372   if (test_pvremove_1 () == -1) {
7373     printf ("test_pvremove_1 FAILED\n");
7374     failed++;
7375   }
7376   test_num++;
7377   printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
7378   if (test_pvremove_2 () == -1) {
7379     printf ("test_pvremove_2 FAILED\n");
7380     failed++;
7381   }
7382   test_num++;
7383   printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
7384   if (test_vgremove_0 () == -1) {
7385     printf ("test_vgremove_0 FAILED\n");
7386     failed++;
7387   }
7388   test_num++;
7389   printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
7390   if (test_vgremove_1 () == -1) {
7391     printf ("test_vgremove_1 FAILED\n");
7392     failed++;
7393   }
7394   test_num++;
7395   printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
7396   if (test_lvremove_0 () == -1) {
7397     printf ("test_lvremove_0 FAILED\n");
7398     failed++;
7399   }
7400   test_num++;
7401   printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
7402   if (test_lvremove_1 () == -1) {
7403     printf ("test_lvremove_1 FAILED\n");
7404     failed++;
7405   }
7406   test_num++;
7407   printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
7408   if (test_lvremove_2 () == -1) {
7409     printf ("test_lvremove_2 FAILED\n");
7410     failed++;
7411   }
7412   test_num++;
7413   printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
7414   if (test_mount_ro_0 () == -1) {
7415     printf ("test_mount_ro_0 FAILED\n");
7416     failed++;
7417   }
7418   test_num++;
7419   printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
7420   if (test_mount_ro_1 () == -1) {
7421     printf ("test_mount_ro_1 FAILED\n");
7422     failed++;
7423   }
7424   test_num++;
7425   printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
7426   if (test_tgz_in_0 () == -1) {
7427     printf ("test_tgz_in_0 FAILED\n");
7428     failed++;
7429   }
7430   test_num++;
7431   printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
7432   if (test_tar_in_0 () == -1) {
7433     printf ("test_tar_in_0 FAILED\n");
7434     failed++;
7435   }
7436   test_num++;
7437   printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
7438   if (test_checksum_0 () == -1) {
7439     printf ("test_checksum_0 FAILED\n");
7440     failed++;
7441   }
7442   test_num++;
7443   printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
7444   if (test_checksum_1 () == -1) {
7445     printf ("test_checksum_1 FAILED\n");
7446     failed++;
7447   }
7448   test_num++;
7449   printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
7450   if (test_checksum_2 () == -1) {
7451     printf ("test_checksum_2 FAILED\n");
7452     failed++;
7453   }
7454   test_num++;
7455   printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
7456   if (test_checksum_3 () == -1) {
7457     printf ("test_checksum_3 FAILED\n");
7458     failed++;
7459   }
7460   test_num++;
7461   printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
7462   if (test_checksum_4 () == -1) {
7463     printf ("test_checksum_4 FAILED\n");
7464     failed++;
7465   }
7466   test_num++;
7467   printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
7468   if (test_checksum_5 () == -1) {
7469     printf ("test_checksum_5 FAILED\n");
7470     failed++;
7471   }
7472   test_num++;
7473   printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
7474   if (test_checksum_6 () == -1) {
7475     printf ("test_checksum_6 FAILED\n");
7476     failed++;
7477   }
7478   test_num++;
7479   printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
7480   if (test_checksum_7 () == -1) {
7481     printf ("test_checksum_7 FAILED\n");
7482     failed++;
7483   }
7484   test_num++;
7485   printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
7486   if (test_download_0 () == -1) {
7487     printf ("test_download_0 FAILED\n");
7488     failed++;
7489   }
7490   test_num++;
7491   printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
7492   if (test_upload_0 () == -1) {
7493     printf ("test_upload_0 FAILED\n");
7494     failed++;
7495   }
7496   test_num++;
7497   printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
7498   if (test_blockdev_rereadpt_0 () == -1) {
7499     printf ("test_blockdev_rereadpt_0 FAILED\n");
7500     failed++;
7501   }
7502   test_num++;
7503   printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
7504   if (test_blockdev_flushbufs_0 () == -1) {
7505     printf ("test_blockdev_flushbufs_0 FAILED\n");
7506     failed++;
7507   }
7508   test_num++;
7509   printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
7510   if (test_blockdev_getsize64_0 () == -1) {
7511     printf ("test_blockdev_getsize64_0 FAILED\n");
7512     failed++;
7513   }
7514   test_num++;
7515   printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
7516   if (test_blockdev_getsz_0 () == -1) {
7517     printf ("test_blockdev_getsz_0 FAILED\n");
7518     failed++;
7519   }
7520   test_num++;
7521   printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
7522   if (test_blockdev_getbsz_0 () == -1) {
7523     printf ("test_blockdev_getbsz_0 FAILED\n");
7524     failed++;
7525   }
7526   test_num++;
7527   printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
7528   if (test_blockdev_getss_0 () == -1) {
7529     printf ("test_blockdev_getss_0 FAILED\n");
7530     failed++;
7531   }
7532   test_num++;
7533   printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
7534   if (test_blockdev_getro_0 () == -1) {
7535     printf ("test_blockdev_getro_0 FAILED\n");
7536     failed++;
7537   }
7538   test_num++;
7539   printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
7540   if (test_blockdev_setrw_0 () == -1) {
7541     printf ("test_blockdev_setrw_0 FAILED\n");
7542     failed++;
7543   }
7544   test_num++;
7545   printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
7546   if (test_blockdev_setro_0 () == -1) {
7547     printf ("test_blockdev_setro_0 FAILED\n");
7548     failed++;
7549   }
7550   test_num++;
7551   printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
7552   if (test_statvfs_0 () == -1) {
7553     printf ("test_statvfs_0 FAILED\n");
7554     failed++;
7555   }
7556   test_num++;
7557   printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
7558   if (test_lstat_0 () == -1) {
7559     printf ("test_lstat_0 FAILED\n");
7560     failed++;
7561   }
7562   test_num++;
7563   printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
7564   if (test_stat_0 () == -1) {
7565     printf ("test_stat_0 FAILED\n");
7566     failed++;
7567   }
7568   test_num++;
7569   printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
7570   if (test_file_0 () == -1) {
7571     printf ("test_file_0 FAILED\n");
7572     failed++;
7573   }
7574   test_num++;
7575   printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
7576   if (test_file_1 () == -1) {
7577     printf ("test_file_1 FAILED\n");
7578     failed++;
7579   }
7580   test_num++;
7581   printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
7582   if (test_file_2 () == -1) {
7583     printf ("test_file_2 FAILED\n");
7584     failed++;
7585   }
7586   test_num++;
7587   printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
7588   if (test_umount_all_0 () == -1) {
7589     printf ("test_umount_all_0 FAILED\n");
7590     failed++;
7591   }
7592   test_num++;
7593   printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
7594   if (test_umount_all_1 () == -1) {
7595     printf ("test_umount_all_1 FAILED\n");
7596     failed++;
7597   }
7598   test_num++;
7599   printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
7600   if (test_mounts_0 () == -1) {
7601     printf ("test_mounts_0 FAILED\n");
7602     failed++;
7603   }
7604   test_num++;
7605   printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
7606   if (test_umount_0 () == -1) {
7607     printf ("test_umount_0 FAILED\n");
7608     failed++;
7609   }
7610   test_num++;
7611   printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
7612   if (test_umount_1 () == -1) {
7613     printf ("test_umount_1 FAILED\n");
7614     failed++;
7615   }
7616   test_num++;
7617   printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
7618   if (test_write_file_0 () == -1) {
7619     printf ("test_write_file_0 FAILED\n");
7620     failed++;
7621   }
7622   test_num++;
7623   printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
7624   if (test_write_file_1 () == -1) {
7625     printf ("test_write_file_1 FAILED\n");
7626     failed++;
7627   }
7628   test_num++;
7629   printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
7630   if (test_write_file_2 () == -1) {
7631     printf ("test_write_file_2 FAILED\n");
7632     failed++;
7633   }
7634   test_num++;
7635   printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
7636   if (test_write_file_3 () == -1) {
7637     printf ("test_write_file_3 FAILED\n");
7638     failed++;
7639   }
7640   test_num++;
7641   printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
7642   if (test_write_file_4 () == -1) {
7643     printf ("test_write_file_4 FAILED\n");
7644     failed++;
7645   }
7646   test_num++;
7647   printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
7648   if (test_write_file_5 () == -1) {
7649     printf ("test_write_file_5 FAILED\n");
7650     failed++;
7651   }
7652   test_num++;
7653   printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
7654   if (test_mkfs_0 () == -1) {
7655     printf ("test_mkfs_0 FAILED\n");
7656     failed++;
7657   }
7658   test_num++;
7659   printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
7660   if (test_lvcreate_0 () == -1) {
7661     printf ("test_lvcreate_0 FAILED\n");
7662     failed++;
7663   }
7664   test_num++;
7665   printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
7666   if (test_vgcreate_0 () == -1) {
7667     printf ("test_vgcreate_0 FAILED\n");
7668     failed++;
7669   }
7670   test_num++;
7671   printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
7672   if (test_pvcreate_0 () == -1) {
7673     printf ("test_pvcreate_0 FAILED\n");
7674     failed++;
7675   }
7676   test_num++;
7677   printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
7678   if (test_is_dir_0 () == -1) {
7679     printf ("test_is_dir_0 FAILED\n");
7680     failed++;
7681   }
7682   test_num++;
7683   printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
7684   if (test_is_dir_1 () == -1) {
7685     printf ("test_is_dir_1 FAILED\n");
7686     failed++;
7687   }
7688   test_num++;
7689   printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
7690   if (test_is_file_0 () == -1) {
7691     printf ("test_is_file_0 FAILED\n");
7692     failed++;
7693   }
7694   test_num++;
7695   printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
7696   if (test_is_file_1 () == -1) {
7697     printf ("test_is_file_1 FAILED\n");
7698     failed++;
7699   }
7700   test_num++;
7701   printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
7702   if (test_exists_0 () == -1) {
7703     printf ("test_exists_0 FAILED\n");
7704     failed++;
7705   }
7706   test_num++;
7707   printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
7708   if (test_exists_1 () == -1) {
7709     printf ("test_exists_1 FAILED\n");
7710     failed++;
7711   }
7712   test_num++;
7713   printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
7714   if (test_mkdir_p_0 () == -1) {
7715     printf ("test_mkdir_p_0 FAILED\n");
7716     failed++;
7717   }
7718   test_num++;
7719   printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
7720   if (test_mkdir_p_1 () == -1) {
7721     printf ("test_mkdir_p_1 FAILED\n");
7722     failed++;
7723   }
7724   test_num++;
7725   printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
7726   if (test_mkdir_p_2 () == -1) {
7727     printf ("test_mkdir_p_2 FAILED\n");
7728     failed++;
7729   }
7730   test_num++;
7731   printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
7732   if (test_mkdir_0 () == -1) {
7733     printf ("test_mkdir_0 FAILED\n");
7734     failed++;
7735   }
7736   test_num++;
7737   printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
7738   if (test_mkdir_1 () == -1) {
7739     printf ("test_mkdir_1 FAILED\n");
7740     failed++;
7741   }
7742   test_num++;
7743   printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
7744   if (test_rm_rf_0 () == -1) {
7745     printf ("test_rm_rf_0 FAILED\n");
7746     failed++;
7747   }
7748   test_num++;
7749   printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
7750   if (test_rmdir_0 () == -1) {
7751     printf ("test_rmdir_0 FAILED\n");
7752     failed++;
7753   }
7754   test_num++;
7755   printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
7756   if (test_rmdir_1 () == -1) {
7757     printf ("test_rmdir_1 FAILED\n");
7758     failed++;
7759   }
7760   test_num++;
7761   printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
7762   if (test_rmdir_2 () == -1) {
7763     printf ("test_rmdir_2 FAILED\n");
7764     failed++;
7765   }
7766   test_num++;
7767   printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
7768   if (test_rm_0 () == -1) {
7769     printf ("test_rm_0 FAILED\n");
7770     failed++;
7771   }
7772   test_num++;
7773   printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
7774   if (test_rm_1 () == -1) {
7775     printf ("test_rm_1 FAILED\n");
7776     failed++;
7777   }
7778   test_num++;
7779   printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
7780   if (test_rm_2 () == -1) {
7781     printf ("test_rm_2 FAILED\n");
7782     failed++;
7783   }
7784   test_num++;
7785   printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
7786   if (test_read_lines_0 () == -1) {
7787     printf ("test_read_lines_0 FAILED\n");
7788     failed++;
7789   }
7790   test_num++;
7791   printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
7792   if (test_read_lines_1 () == -1) {
7793     printf ("test_read_lines_1 FAILED\n");
7794     failed++;
7795   }
7796   test_num++;
7797   printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
7798   if (test_lvs_0 () == -1) {
7799     printf ("test_lvs_0 FAILED\n");
7800     failed++;
7801   }
7802   test_num++;
7803   printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
7804   if (test_lvs_1 () == -1) {
7805     printf ("test_lvs_1 FAILED\n");
7806     failed++;
7807   }
7808   test_num++;
7809   printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
7810   if (test_vgs_0 () == -1) {
7811     printf ("test_vgs_0 FAILED\n");
7812     failed++;
7813   }
7814   test_num++;
7815   printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
7816   if (test_vgs_1 () == -1) {
7817     printf ("test_vgs_1 FAILED\n");
7818     failed++;
7819   }
7820   test_num++;
7821   printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
7822   if (test_pvs_0 () == -1) {
7823     printf ("test_pvs_0 FAILED\n");
7824     failed++;
7825   }
7826   test_num++;
7827   printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
7828   if (test_pvs_1 () == -1) {
7829     printf ("test_pvs_1 FAILED\n");
7830     failed++;
7831   }
7832   test_num++;
7833   printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
7834   if (test_list_partitions_0 () == -1) {
7835     printf ("test_list_partitions_0 FAILED\n");
7836     failed++;
7837   }
7838   test_num++;
7839   printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
7840   if (test_list_partitions_1 () == -1) {
7841     printf ("test_list_partitions_1 FAILED\n");
7842     failed++;
7843   }
7844   test_num++;
7845   printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
7846   if (test_list_devices_0 () == -1) {
7847     printf ("test_list_devices_0 FAILED\n");
7848     failed++;
7849   }
7850   test_num++;
7851   printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
7852   if (test_ls_0 () == -1) {
7853     printf ("test_ls_0 FAILED\n");
7854     failed++;
7855   }
7856   test_num++;
7857   printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
7858   if (test_cat_0 () == -1) {
7859     printf ("test_cat_0 FAILED\n");
7860     failed++;
7861   }
7862   test_num++;
7863   printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
7864   if (test_touch_0 () == -1) {
7865     printf ("test_touch_0 FAILED\n");
7866     failed++;
7867   }
7868   test_num++;
7869   printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
7870   if (test_sync_0 () == -1) {
7871     printf ("test_sync_0 FAILED\n");
7872     failed++;
7873   }
7874   test_num++;
7875   printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
7876   if (test_mount_0 () == -1) {
7877     printf ("test_mount_0 FAILED\n");
7878     failed++;
7879   }
7880
7881   guestfs_close (g);
7882   unlink ("test1.img");
7883   unlink ("test2.img");
7884   unlink ("test3.img");
7885
7886   if (failed > 0) {
7887     printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);
7888     exit (1);
7889   }
7890
7891   exit (0);
7892 }