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