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