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