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