Generated code to support previous 2 commits.
[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 /* This will be 's' or 'h' depending on whether the guest kernel
35  * names IDE devices /dev/sd* or /dev/hd*.
36  */
37 static char devchar = 's';
38
39 static void print_error (guestfs_h *g, void *data, const char *msg)
40 {
41   if (!suppress_error)
42     fprintf (stderr, "%s\n", msg);
43 }
44
45 static void print_strings (char * const * const argv)
46 {
47   int argc;
48
49   for (argc = 0; argv[argc] != NULL; ++argc)
50     printf ("\t%s\n", argv[argc]);
51 }
52
53 /*
54 static void print_table (char * const * const argv)
55 {
56   int i;
57
58   for (i = 0; argv[i] != NULL; i += 2)
59     printf ("%s: %s\n", argv[i], argv[i+1]);
60 }
61 */
62
63 static void no_test_warnings (void)
64 {
65   fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
66   fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
67   fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
68   fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
69   fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
70   fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
71   fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
72   fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
73   fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
74   fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
75   fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
76   fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
77   fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
78   fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
79   fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
80   fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
81   fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
82   fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
83   fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
84   fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
85   fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
86   fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
87   fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
88   fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
89   fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
90   fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
91   fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
92   fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
93   fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
94   fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
95   fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
96   fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
97   fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
98   fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
99   fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
100   fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
101   fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
102   fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
103   fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
104   fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
105   fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
106   fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
107   fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
108   fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
109   fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
110   fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
111   fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
112   fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
113   fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
114   fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
115   fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
116   fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
117   fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
118 }
119
120 static int test_hexdump_0 (void)
121 {
122   /* InitBasicFS for hexdump (0): create ext2 on /dev/sda1 */
123   {
124     char device[] = "/dev/sda";
125     device[5] = devchar;
126     int r;
127     suppress_error = 0;
128     r = guestfs_blockdev_setrw (g, device);
129     if (r == -1)
130       return -1;
131   }
132   {
133     int r;
134     suppress_error = 0;
135     r = guestfs_umount_all (g);
136     if (r == -1)
137       return -1;
138   }
139   {
140     int r;
141     suppress_error = 0;
142     r = guestfs_lvm_remove_all (g);
143     if (r == -1)
144       return -1;
145   }
146   {
147     char device[] = "/dev/sda";
148     device[5] = devchar;
149     char lines_0[] = ",";
150     char *lines[] = {
151       lines_0,
152       NULL
153     };
154     int r;
155     suppress_error = 0;
156     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
157     if (r == -1)
158       return -1;
159   }
160   {
161     char fstype[] = "ext2";
162     char device[] = "/dev/sda1";
163     device[5] = devchar;
164     int r;
165     suppress_error = 0;
166     r = guestfs_mkfs (g, fstype, device);
167     if (r == -1)
168       return -1;
169   }
170   {
171     char device[] = "/dev/sda1";
172     device[5] = devchar;
173     char mountpoint[] = "/";
174     int r;
175     suppress_error = 0;
176     r = guestfs_mount (g, device, mountpoint);
177     if (r == -1)
178       return -1;
179   }
180   /* TestOutput for hexdump (0) */
181   char expected[] = "00000000  68 65 6c 6c 6f 0a 77 6f  72 6c 64 0a              |hello.world.|\n0000000c\n";
182   {
183     char path[] = "/new";
184     char content[] = "hello\nworld\n";
185     int r;
186     suppress_error = 0;
187     r = guestfs_write_file (g, path, content, 12);
188     if (r == -1)
189       return -1;
190   }
191   {
192     char path[] = "/new";
193     char *r;
194     suppress_error = 0;
195     r = guestfs_hexdump (g, path);
196     if (r == NULL)
197       return -1;
198     if (strcmp (r, expected) != 0) {
199       fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
200       return -1;
201     }
202     free (r);
203   }
204   return 0;
205 }
206
207 static int test_strings_e_0 (void)
208 {
209   /* InitBasicFS for strings_e (0): create ext2 on /dev/sda1 */
210   {
211     char device[] = "/dev/sda";
212     device[5] = devchar;
213     int r;
214     suppress_error = 0;
215     r = guestfs_blockdev_setrw (g, device);
216     if (r == -1)
217       return -1;
218   }
219   {
220     int r;
221     suppress_error = 0;
222     r = guestfs_umount_all (g);
223     if (r == -1)
224       return -1;
225   }
226   {
227     int r;
228     suppress_error = 0;
229     r = guestfs_lvm_remove_all (g);
230     if (r == -1)
231       return -1;
232   }
233   {
234     char device[] = "/dev/sda";
235     device[5] = devchar;
236     char lines_0[] = ",";
237     char *lines[] = {
238       lines_0,
239       NULL
240     };
241     int r;
242     suppress_error = 0;
243     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
244     if (r == -1)
245       return -1;
246   }
247   {
248     char fstype[] = "ext2";
249     char device[] = "/dev/sda1";
250     device[5] = devchar;
251     int r;
252     suppress_error = 0;
253     r = guestfs_mkfs (g, fstype, device);
254     if (r == -1)
255       return -1;
256   }
257   {
258     char device[] = "/dev/sda1";
259     device[5] = devchar;
260     char mountpoint[] = "/";
261     int r;
262     suppress_error = 0;
263     r = guestfs_mount (g, device, mountpoint);
264     if (r == -1)
265       return -1;
266   }
267   /* TestOutputList for strings_e (0) */
268   {
269     char path[] = "/new";
270     char content[] = "hello\nworld\n";
271     int r;
272     suppress_error = 0;
273     r = guestfs_write_file (g, path, content, 0);
274     if (r == -1)
275       return -1;
276   }
277   {
278     char encoding[] = "b";
279     char path[] = "/new";
280     char **r;
281     int i;
282     suppress_error = 0;
283     r = guestfs_strings_e (g, encoding, path);
284     if (r == NULL)
285       return -1;
286     if (r[0] != NULL) {
287       fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
288       print_strings (r);
289       return -1;
290     }
291     for (i = 0; r[i] != NULL; ++i)
292       free (r[i]);
293     free (r);
294   }
295   return 0;
296 }
297
298 static int test_strings_0 (void)
299 {
300   /* InitBasicFS for strings (0): create ext2 on /dev/sda1 */
301   {
302     char device[] = "/dev/sda";
303     device[5] = devchar;
304     int r;
305     suppress_error = 0;
306     r = guestfs_blockdev_setrw (g, device);
307     if (r == -1)
308       return -1;
309   }
310   {
311     int r;
312     suppress_error = 0;
313     r = guestfs_umount_all (g);
314     if (r == -1)
315       return -1;
316   }
317   {
318     int r;
319     suppress_error = 0;
320     r = guestfs_lvm_remove_all (g);
321     if (r == -1)
322       return -1;
323   }
324   {
325     char device[] = "/dev/sda";
326     device[5] = devchar;
327     char lines_0[] = ",";
328     char *lines[] = {
329       lines_0,
330       NULL
331     };
332     int r;
333     suppress_error = 0;
334     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
335     if (r == -1)
336       return -1;
337   }
338   {
339     char fstype[] = "ext2";
340     char device[] = "/dev/sda1";
341     device[5] = devchar;
342     int r;
343     suppress_error = 0;
344     r = guestfs_mkfs (g, fstype, device);
345     if (r == -1)
346       return -1;
347   }
348   {
349     char device[] = "/dev/sda1";
350     device[5] = devchar;
351     char mountpoint[] = "/";
352     int r;
353     suppress_error = 0;
354     r = guestfs_mount (g, device, mountpoint);
355     if (r == -1)
356       return -1;
357   }
358   /* TestOutputList for strings (0) */
359   {
360     char path[] = "/new";
361     char content[] = "hello\nworld\n";
362     int r;
363     suppress_error = 0;
364     r = guestfs_write_file (g, path, content, 0);
365     if (r == -1)
366       return -1;
367   }
368   {
369     char path[] = "/new";
370     char **r;
371     int i;
372     suppress_error = 0;
373     r = guestfs_strings (g, path);
374     if (r == NULL)
375       return -1;
376     if (!r[0]) {
377       fprintf (stderr, "test_strings_0: short list returned from command\n");
378       print_strings (r);
379       return -1;
380     }
381     {
382       char expected[] = "hello";
383       if (strcmp (r[0], expected) != 0) {
384         fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
385         return -1;
386       }
387     }
388     if (!r[1]) {
389       fprintf (stderr, "test_strings_0: short list returned from command\n");
390       print_strings (r);
391       return -1;
392     }
393     {
394       char expected[] = "world";
395       if (strcmp (r[1], expected) != 0) {
396         fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
397         return -1;
398       }
399     }
400     if (r[2] != NULL) {
401       fprintf (stderr, "test_strings_0: extra elements returned from command\n");
402       print_strings (r);
403       return -1;
404     }
405     for (i = 0; r[i] != NULL; ++i)
406       free (r[i]);
407     free (r);
408   }
409   return 0;
410 }
411
412 static int test_equal_0 (void)
413 {
414   /* InitBasicFS for equal (0): create ext2 on /dev/sda1 */
415   {
416     char device[] = "/dev/sda";
417     device[5] = devchar;
418     int r;
419     suppress_error = 0;
420     r = guestfs_blockdev_setrw (g, device);
421     if (r == -1)
422       return -1;
423   }
424   {
425     int r;
426     suppress_error = 0;
427     r = guestfs_umount_all (g);
428     if (r == -1)
429       return -1;
430   }
431   {
432     int r;
433     suppress_error = 0;
434     r = guestfs_lvm_remove_all (g);
435     if (r == -1)
436       return -1;
437   }
438   {
439     char device[] = "/dev/sda";
440     device[5] = devchar;
441     char lines_0[] = ",";
442     char *lines[] = {
443       lines_0,
444       NULL
445     };
446     int r;
447     suppress_error = 0;
448     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
449     if (r == -1)
450       return -1;
451   }
452   {
453     char fstype[] = "ext2";
454     char device[] = "/dev/sda1";
455     device[5] = devchar;
456     int r;
457     suppress_error = 0;
458     r = guestfs_mkfs (g, fstype, device);
459     if (r == -1)
460       return -1;
461   }
462   {
463     char device[] = "/dev/sda1";
464     device[5] = devchar;
465     char mountpoint[] = "/";
466     int r;
467     suppress_error = 0;
468     r = guestfs_mount (g, device, mountpoint);
469     if (r == -1)
470       return -1;
471   }
472   /* TestOutputTrue for equal (0) */
473   {
474     char path[] = "/file1";
475     char content[] = "contents of a file";
476     int r;
477     suppress_error = 0;
478     r = guestfs_write_file (g, path, content, 0);
479     if (r == -1)
480       return -1;
481   }
482   {
483     char src[] = "/file1";
484     char dest[] = "/file2";
485     int r;
486     suppress_error = 0;
487     r = guestfs_cp (g, src, dest);
488     if (r == -1)
489       return -1;
490   }
491   {
492     char file1[] = "/file1";
493     char file2[] = "/file2";
494     int r;
495     suppress_error = 0;
496     r = guestfs_equal (g, file1, file2);
497     if (r == -1)
498       return -1;
499     if (!r) {
500       fprintf (stderr, "test_equal_0: expected true, got false\n");
501       return -1;
502     }
503   }
504   return 0;
505 }
506
507 static int test_equal_1 (void)
508 {
509   /* InitBasicFS for equal (1): create ext2 on /dev/sda1 */
510   {
511     char device[] = "/dev/sda";
512     device[5] = devchar;
513     int r;
514     suppress_error = 0;
515     r = guestfs_blockdev_setrw (g, device);
516     if (r == -1)
517       return -1;
518   }
519   {
520     int r;
521     suppress_error = 0;
522     r = guestfs_umount_all (g);
523     if (r == -1)
524       return -1;
525   }
526   {
527     int r;
528     suppress_error = 0;
529     r = guestfs_lvm_remove_all (g);
530     if (r == -1)
531       return -1;
532   }
533   {
534     char device[] = "/dev/sda";
535     device[5] = devchar;
536     char lines_0[] = ",";
537     char *lines[] = {
538       lines_0,
539       NULL
540     };
541     int r;
542     suppress_error = 0;
543     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
544     if (r == -1)
545       return -1;
546   }
547   {
548     char fstype[] = "ext2";
549     char device[] = "/dev/sda1";
550     device[5] = devchar;
551     int r;
552     suppress_error = 0;
553     r = guestfs_mkfs (g, fstype, device);
554     if (r == -1)
555       return -1;
556   }
557   {
558     char device[] = "/dev/sda1";
559     device[5] = devchar;
560     char mountpoint[] = "/";
561     int r;
562     suppress_error = 0;
563     r = guestfs_mount (g, device, mountpoint);
564     if (r == -1)
565       return -1;
566   }
567   /* TestOutputFalse for equal (1) */
568   {
569     char path[] = "/file1";
570     char content[] = "contents of a file";
571     int r;
572     suppress_error = 0;
573     r = guestfs_write_file (g, path, content, 0);
574     if (r == -1)
575       return -1;
576   }
577   {
578     char path[] = "/file2";
579     char content[] = "contents of another file";
580     int r;
581     suppress_error = 0;
582     r = guestfs_write_file (g, path, content, 0);
583     if (r == -1)
584       return -1;
585   }
586   {
587     char file1[] = "/file1";
588     char file2[] = "/file2";
589     int r;
590     suppress_error = 0;
591     r = guestfs_equal (g, file1, file2);
592     if (r == -1)
593       return -1;
594     if (r) {
595       fprintf (stderr, "test_equal_1: expected false, got true\n");
596       return -1;
597     }
598   }
599   return 0;
600 }
601
602 static int test_equal_2 (void)
603 {
604   /* InitBasicFS for equal (2): create ext2 on /dev/sda1 */
605   {
606     char device[] = "/dev/sda";
607     device[5] = devchar;
608     int r;
609     suppress_error = 0;
610     r = guestfs_blockdev_setrw (g, device);
611     if (r == -1)
612       return -1;
613   }
614   {
615     int r;
616     suppress_error = 0;
617     r = guestfs_umount_all (g);
618     if (r == -1)
619       return -1;
620   }
621   {
622     int r;
623     suppress_error = 0;
624     r = guestfs_lvm_remove_all (g);
625     if (r == -1)
626       return -1;
627   }
628   {
629     char device[] = "/dev/sda";
630     device[5] = devchar;
631     char lines_0[] = ",";
632     char *lines[] = {
633       lines_0,
634       NULL
635     };
636     int r;
637     suppress_error = 0;
638     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
639     if (r == -1)
640       return -1;
641   }
642   {
643     char fstype[] = "ext2";
644     char device[] = "/dev/sda1";
645     device[5] = devchar;
646     int r;
647     suppress_error = 0;
648     r = guestfs_mkfs (g, fstype, device);
649     if (r == -1)
650       return -1;
651   }
652   {
653     char device[] = "/dev/sda1";
654     device[5] = devchar;
655     char mountpoint[] = "/";
656     int r;
657     suppress_error = 0;
658     r = guestfs_mount (g, device, mountpoint);
659     if (r == -1)
660       return -1;
661   }
662   /* TestLastFail for equal (2) */
663   {
664     char file1[] = "/file1";
665     char file2[] = "/file2";
666     int r;
667     suppress_error = 1;
668     r = guestfs_equal (g, file1, file2);
669     if (r != -1)
670       return -1;
671   }
672   return 0;
673 }
674
675 static int test_ping_daemon_0 (void)
676 {
677   /* InitEmpty for ping_daemon (0) */
678   {
679     char device[] = "/dev/sda";
680     device[5] = devchar;
681     int r;
682     suppress_error = 0;
683     r = guestfs_blockdev_setrw (g, device);
684     if (r == -1)
685       return -1;
686   }
687   {
688     int r;
689     suppress_error = 0;
690     r = guestfs_umount_all (g);
691     if (r == -1)
692       return -1;
693   }
694   {
695     int r;
696     suppress_error = 0;
697     r = guestfs_lvm_remove_all (g);
698     if (r == -1)
699       return -1;
700   }
701   /* TestRun for ping_daemon (0) */
702   {
703     int r;
704     suppress_error = 0;
705     r = guestfs_ping_daemon (g);
706     if (r == -1)
707       return -1;
708   }
709   return 0;
710 }
711
712 static int test_dmesg_0 (void)
713 {
714   /* InitEmpty for dmesg (0) */
715   {
716     char device[] = "/dev/sda";
717     device[5] = devchar;
718     int r;
719     suppress_error = 0;
720     r = guestfs_blockdev_setrw (g, device);
721     if (r == -1)
722       return -1;
723   }
724   {
725     int r;
726     suppress_error = 0;
727     r = guestfs_umount_all (g);
728     if (r == -1)
729       return -1;
730   }
731   {
732     int r;
733     suppress_error = 0;
734     r = guestfs_lvm_remove_all (g);
735     if (r == -1)
736       return -1;
737   }
738   /* TestRun for dmesg (0) */
739   {
740     char *r;
741     suppress_error = 0;
742     r = guestfs_dmesg (g);
743     if (r == NULL)
744       return -1;
745     free (r);
746   }
747   return 0;
748 }
749
750 static int test_drop_caches_0 (void)
751 {
752   /* InitEmpty for drop_caches (0) */
753   {
754     char device[] = "/dev/sda";
755     device[5] = devchar;
756     int r;
757     suppress_error = 0;
758     r = guestfs_blockdev_setrw (g, device);
759     if (r == -1)
760       return -1;
761   }
762   {
763     int r;
764     suppress_error = 0;
765     r = guestfs_umount_all (g);
766     if (r == -1)
767       return -1;
768   }
769   {
770     int r;
771     suppress_error = 0;
772     r = guestfs_lvm_remove_all (g);
773     if (r == -1)
774       return -1;
775   }
776   /* TestRun for drop_caches (0) */
777   {
778     int r;
779     suppress_error = 0;
780     r = guestfs_drop_caches (g, 3);
781     if (r == -1)
782       return -1;
783   }
784   return 0;
785 }
786
787 static int test_mv_0 (void)
788 {
789   /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
790   {
791     char device[] = "/dev/sda";
792     device[5] = devchar;
793     int r;
794     suppress_error = 0;
795     r = guestfs_blockdev_setrw (g, device);
796     if (r == -1)
797       return -1;
798   }
799   {
800     int r;
801     suppress_error = 0;
802     r = guestfs_umount_all (g);
803     if (r == -1)
804       return -1;
805   }
806   {
807     int r;
808     suppress_error = 0;
809     r = guestfs_lvm_remove_all (g);
810     if (r == -1)
811       return -1;
812   }
813   {
814     char device[] = "/dev/sda";
815     device[5] = devchar;
816     char lines_0[] = ",";
817     char *lines[] = {
818       lines_0,
819       NULL
820     };
821     int r;
822     suppress_error = 0;
823     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
824     if (r == -1)
825       return -1;
826   }
827   {
828     char fstype[] = "ext2";
829     char device[] = "/dev/sda1";
830     device[5] = devchar;
831     int r;
832     suppress_error = 0;
833     r = guestfs_mkfs (g, fstype, device);
834     if (r == -1)
835       return -1;
836   }
837   {
838     char device[] = "/dev/sda1";
839     device[5] = devchar;
840     char mountpoint[] = "/";
841     int r;
842     suppress_error = 0;
843     r = guestfs_mount (g, device, mountpoint);
844     if (r == -1)
845       return -1;
846   }
847   /* TestOutput for mv (0) */
848   char expected[] = "file content";
849   {
850     char path[] = "/old";
851     char content[] = "file content";
852     int r;
853     suppress_error = 0;
854     r = guestfs_write_file (g, path, content, 0);
855     if (r == -1)
856       return -1;
857   }
858   {
859     char src[] = "/old";
860     char dest[] = "/new";
861     int r;
862     suppress_error = 0;
863     r = guestfs_mv (g, src, dest);
864     if (r == -1)
865       return -1;
866   }
867   {
868     char path[] = "/new";
869     char *r;
870     suppress_error = 0;
871     r = guestfs_cat (g, path);
872     if (r == NULL)
873       return -1;
874     if (strcmp (r, expected) != 0) {
875       fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
876       return -1;
877     }
878     free (r);
879   }
880   return 0;
881 }
882
883 static int test_mv_1 (void)
884 {
885   /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
886   {
887     char device[] = "/dev/sda";
888     device[5] = devchar;
889     int r;
890     suppress_error = 0;
891     r = guestfs_blockdev_setrw (g, device);
892     if (r == -1)
893       return -1;
894   }
895   {
896     int r;
897     suppress_error = 0;
898     r = guestfs_umount_all (g);
899     if (r == -1)
900       return -1;
901   }
902   {
903     int r;
904     suppress_error = 0;
905     r = guestfs_lvm_remove_all (g);
906     if (r == -1)
907       return -1;
908   }
909   {
910     char device[] = "/dev/sda";
911     device[5] = devchar;
912     char lines_0[] = ",";
913     char *lines[] = {
914       lines_0,
915       NULL
916     };
917     int r;
918     suppress_error = 0;
919     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
920     if (r == -1)
921       return -1;
922   }
923   {
924     char fstype[] = "ext2";
925     char device[] = "/dev/sda1";
926     device[5] = devchar;
927     int r;
928     suppress_error = 0;
929     r = guestfs_mkfs (g, fstype, device);
930     if (r == -1)
931       return -1;
932   }
933   {
934     char device[] = "/dev/sda1";
935     device[5] = devchar;
936     char mountpoint[] = "/";
937     int r;
938     suppress_error = 0;
939     r = guestfs_mount (g, device, mountpoint);
940     if (r == -1)
941       return -1;
942   }
943   /* TestOutputFalse for mv (1) */
944   {
945     char path[] = "/old";
946     char content[] = "file content";
947     int r;
948     suppress_error = 0;
949     r = guestfs_write_file (g, path, content, 0);
950     if (r == -1)
951       return -1;
952   }
953   {
954     char src[] = "/old";
955     char dest[] = "/new";
956     int r;
957     suppress_error = 0;
958     r = guestfs_mv (g, src, dest);
959     if (r == -1)
960       return -1;
961   }
962   {
963     char path[] = "/old";
964     int r;
965     suppress_error = 0;
966     r = guestfs_is_file (g, path);
967     if (r == -1)
968       return -1;
969     if (r) {
970       fprintf (stderr, "test_mv_1: expected false, got true\n");
971       return -1;
972     }
973   }
974   return 0;
975 }
976
977 static int test_cp_a_0 (void)
978 {
979   /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
980   {
981     char device[] = "/dev/sda";
982     device[5] = devchar;
983     int r;
984     suppress_error = 0;
985     r = guestfs_blockdev_setrw (g, device);
986     if (r == -1)
987       return -1;
988   }
989   {
990     int r;
991     suppress_error = 0;
992     r = guestfs_umount_all (g);
993     if (r == -1)
994       return -1;
995   }
996   {
997     int r;
998     suppress_error = 0;
999     r = guestfs_lvm_remove_all (g);
1000     if (r == -1)
1001       return -1;
1002   }
1003   {
1004     char device[] = "/dev/sda";
1005     device[5] = devchar;
1006     char lines_0[] = ",";
1007     char *lines[] = {
1008       lines_0,
1009       NULL
1010     };
1011     int r;
1012     suppress_error = 0;
1013     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1014     if (r == -1)
1015       return -1;
1016   }
1017   {
1018     char fstype[] = "ext2";
1019     char device[] = "/dev/sda1";
1020     device[5] = devchar;
1021     int r;
1022     suppress_error = 0;
1023     r = guestfs_mkfs (g, fstype, device);
1024     if (r == -1)
1025       return -1;
1026   }
1027   {
1028     char device[] = "/dev/sda1";
1029     device[5] = devchar;
1030     char mountpoint[] = "/";
1031     int r;
1032     suppress_error = 0;
1033     r = guestfs_mount (g, device, mountpoint);
1034     if (r == -1)
1035       return -1;
1036   }
1037   /* TestOutput for cp_a (0) */
1038   char expected[] = "file content";
1039   {
1040     char path[] = "/olddir";
1041     int r;
1042     suppress_error = 0;
1043     r = guestfs_mkdir (g, path);
1044     if (r == -1)
1045       return -1;
1046   }
1047   {
1048     char path[] = "/newdir";
1049     int r;
1050     suppress_error = 0;
1051     r = guestfs_mkdir (g, path);
1052     if (r == -1)
1053       return -1;
1054   }
1055   {
1056     char path[] = "/olddir/file";
1057     char content[] = "file content";
1058     int r;
1059     suppress_error = 0;
1060     r = guestfs_write_file (g, path, content, 0);
1061     if (r == -1)
1062       return -1;
1063   }
1064   {
1065     char src[] = "/olddir";
1066     char dest[] = "/newdir";
1067     int r;
1068     suppress_error = 0;
1069     r = guestfs_cp_a (g, src, dest);
1070     if (r == -1)
1071       return -1;
1072   }
1073   {
1074     char path[] = "/newdir/olddir/file";
1075     char *r;
1076     suppress_error = 0;
1077     r = guestfs_cat (g, path);
1078     if (r == NULL)
1079       return -1;
1080     if (strcmp (r, expected) != 0) {
1081       fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
1082       return -1;
1083     }
1084     free (r);
1085   }
1086   return 0;
1087 }
1088
1089 static int test_cp_0 (void)
1090 {
1091   /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
1092   {
1093     char device[] = "/dev/sda";
1094     device[5] = devchar;
1095     int r;
1096     suppress_error = 0;
1097     r = guestfs_blockdev_setrw (g, device);
1098     if (r == -1)
1099       return -1;
1100   }
1101   {
1102     int r;
1103     suppress_error = 0;
1104     r = guestfs_umount_all (g);
1105     if (r == -1)
1106       return -1;
1107   }
1108   {
1109     int r;
1110     suppress_error = 0;
1111     r = guestfs_lvm_remove_all (g);
1112     if (r == -1)
1113       return -1;
1114   }
1115   {
1116     char device[] = "/dev/sda";
1117     device[5] = devchar;
1118     char lines_0[] = ",";
1119     char *lines[] = {
1120       lines_0,
1121       NULL
1122     };
1123     int r;
1124     suppress_error = 0;
1125     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1126     if (r == -1)
1127       return -1;
1128   }
1129   {
1130     char fstype[] = "ext2";
1131     char device[] = "/dev/sda1";
1132     device[5] = devchar;
1133     int r;
1134     suppress_error = 0;
1135     r = guestfs_mkfs (g, fstype, device);
1136     if (r == -1)
1137       return -1;
1138   }
1139   {
1140     char device[] = "/dev/sda1";
1141     device[5] = devchar;
1142     char mountpoint[] = "/";
1143     int r;
1144     suppress_error = 0;
1145     r = guestfs_mount (g, device, mountpoint);
1146     if (r == -1)
1147       return -1;
1148   }
1149   /* TestOutput for cp (0) */
1150   char expected[] = "file content";
1151   {
1152     char path[] = "/old";
1153     char content[] = "file content";
1154     int r;
1155     suppress_error = 0;
1156     r = guestfs_write_file (g, path, content, 0);
1157     if (r == -1)
1158       return -1;
1159   }
1160   {
1161     char src[] = "/old";
1162     char dest[] = "/new";
1163     int r;
1164     suppress_error = 0;
1165     r = guestfs_cp (g, src, dest);
1166     if (r == -1)
1167       return -1;
1168   }
1169   {
1170     char path[] = "/new";
1171     char *r;
1172     suppress_error = 0;
1173     r = guestfs_cat (g, path);
1174     if (r == NULL)
1175       return -1;
1176     if (strcmp (r, expected) != 0) {
1177       fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
1178       return -1;
1179     }
1180     free (r);
1181   }
1182   return 0;
1183 }
1184
1185 static int test_cp_1 (void)
1186 {
1187   /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
1188   {
1189     char device[] = "/dev/sda";
1190     device[5] = devchar;
1191     int r;
1192     suppress_error = 0;
1193     r = guestfs_blockdev_setrw (g, device);
1194     if (r == -1)
1195       return -1;
1196   }
1197   {
1198     int r;
1199     suppress_error = 0;
1200     r = guestfs_umount_all (g);
1201     if (r == -1)
1202       return -1;
1203   }
1204   {
1205     int r;
1206     suppress_error = 0;
1207     r = guestfs_lvm_remove_all (g);
1208     if (r == -1)
1209       return -1;
1210   }
1211   {
1212     char device[] = "/dev/sda";
1213     device[5] = devchar;
1214     char lines_0[] = ",";
1215     char *lines[] = {
1216       lines_0,
1217       NULL
1218     };
1219     int r;
1220     suppress_error = 0;
1221     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1222     if (r == -1)
1223       return -1;
1224   }
1225   {
1226     char fstype[] = "ext2";
1227     char device[] = "/dev/sda1";
1228     device[5] = devchar;
1229     int r;
1230     suppress_error = 0;
1231     r = guestfs_mkfs (g, fstype, device);
1232     if (r == -1)
1233       return -1;
1234   }
1235   {
1236     char device[] = "/dev/sda1";
1237     device[5] = devchar;
1238     char mountpoint[] = "/";
1239     int r;
1240     suppress_error = 0;
1241     r = guestfs_mount (g, device, mountpoint);
1242     if (r == -1)
1243       return -1;
1244   }
1245   /* TestOutputTrue for cp (1) */
1246   {
1247     char path[] = "/old";
1248     char content[] = "file content";
1249     int r;
1250     suppress_error = 0;
1251     r = guestfs_write_file (g, path, content, 0);
1252     if (r == -1)
1253       return -1;
1254   }
1255   {
1256     char src[] = "/old";
1257     char dest[] = "/new";
1258     int r;
1259     suppress_error = 0;
1260     r = guestfs_cp (g, src, dest);
1261     if (r == -1)
1262       return -1;
1263   }
1264   {
1265     char path[] = "/old";
1266     int r;
1267     suppress_error = 0;
1268     r = guestfs_is_file (g, path);
1269     if (r == -1)
1270       return -1;
1271     if (!r) {
1272       fprintf (stderr, "test_cp_1: expected true, got false\n");
1273       return -1;
1274     }
1275   }
1276   return 0;
1277 }
1278
1279 static int test_cp_2 (void)
1280 {
1281   /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
1282   {
1283     char device[] = "/dev/sda";
1284     device[5] = devchar;
1285     int r;
1286     suppress_error = 0;
1287     r = guestfs_blockdev_setrw (g, device);
1288     if (r == -1)
1289       return -1;
1290   }
1291   {
1292     int r;
1293     suppress_error = 0;
1294     r = guestfs_umount_all (g);
1295     if (r == -1)
1296       return -1;
1297   }
1298   {
1299     int r;
1300     suppress_error = 0;
1301     r = guestfs_lvm_remove_all (g);
1302     if (r == -1)
1303       return -1;
1304   }
1305   {
1306     char device[] = "/dev/sda";
1307     device[5] = devchar;
1308     char lines_0[] = ",";
1309     char *lines[] = {
1310       lines_0,
1311       NULL
1312     };
1313     int r;
1314     suppress_error = 0;
1315     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1316     if (r == -1)
1317       return -1;
1318   }
1319   {
1320     char fstype[] = "ext2";
1321     char device[] = "/dev/sda1";
1322     device[5] = devchar;
1323     int r;
1324     suppress_error = 0;
1325     r = guestfs_mkfs (g, fstype, device);
1326     if (r == -1)
1327       return -1;
1328   }
1329   {
1330     char device[] = "/dev/sda1";
1331     device[5] = devchar;
1332     char mountpoint[] = "/";
1333     int r;
1334     suppress_error = 0;
1335     r = guestfs_mount (g, device, mountpoint);
1336     if (r == -1)
1337       return -1;
1338   }
1339   /* TestOutput for cp (2) */
1340   char expected[] = "file content";
1341   {
1342     char path[] = "/old";
1343     char content[] = "file content";
1344     int r;
1345     suppress_error = 0;
1346     r = guestfs_write_file (g, path, content, 0);
1347     if (r == -1)
1348       return -1;
1349   }
1350   {
1351     char path[] = "/dir";
1352     int r;
1353     suppress_error = 0;
1354     r = guestfs_mkdir (g, path);
1355     if (r == -1)
1356       return -1;
1357   }
1358   {
1359     char src[] = "/old";
1360     char dest[] = "/dir/new";
1361     int r;
1362     suppress_error = 0;
1363     r = guestfs_cp (g, src, dest);
1364     if (r == -1)
1365       return -1;
1366   }
1367   {
1368     char path[] = "/dir/new";
1369     char *r;
1370     suppress_error = 0;
1371     r = guestfs_cat (g, path);
1372     if (r == NULL)
1373       return -1;
1374     if (strcmp (r, expected) != 0) {
1375       fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
1376       return -1;
1377     }
1378     free (r);
1379   }
1380   return 0;
1381 }
1382
1383 static int test_grub_install_0 (void)
1384 {
1385   /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
1386   {
1387     char device[] = "/dev/sda";
1388     device[5] = devchar;
1389     int r;
1390     suppress_error = 0;
1391     r = guestfs_blockdev_setrw (g, device);
1392     if (r == -1)
1393       return -1;
1394   }
1395   {
1396     int r;
1397     suppress_error = 0;
1398     r = guestfs_umount_all (g);
1399     if (r == -1)
1400       return -1;
1401   }
1402   {
1403     int r;
1404     suppress_error = 0;
1405     r = guestfs_lvm_remove_all (g);
1406     if (r == -1)
1407       return -1;
1408   }
1409   {
1410     char device[] = "/dev/sda";
1411     device[5] = devchar;
1412     char lines_0[] = ",";
1413     char *lines[] = {
1414       lines_0,
1415       NULL
1416     };
1417     int r;
1418     suppress_error = 0;
1419     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1420     if (r == -1)
1421       return -1;
1422   }
1423   {
1424     char fstype[] = "ext2";
1425     char device[] = "/dev/sda1";
1426     device[5] = devchar;
1427     int r;
1428     suppress_error = 0;
1429     r = guestfs_mkfs (g, fstype, device);
1430     if (r == -1)
1431       return -1;
1432   }
1433   {
1434     char device[] = "/dev/sda1";
1435     device[5] = devchar;
1436     char mountpoint[] = "/";
1437     int r;
1438     suppress_error = 0;
1439     r = guestfs_mount (g, device, mountpoint);
1440     if (r == -1)
1441       return -1;
1442   }
1443   /* TestOutputTrue for grub_install (0) */
1444   {
1445     char root[] = "/";
1446     char device[] = "/dev/sda1";
1447     device[5] = devchar;
1448     int r;
1449     suppress_error = 0;
1450     r = guestfs_grub_install (g, root, device);
1451     if (r == -1)
1452       return -1;
1453   }
1454   {
1455     char path[] = "/boot";
1456     int r;
1457     suppress_error = 0;
1458     r = guestfs_is_dir (g, path);
1459     if (r == -1)
1460       return -1;
1461     if (!r) {
1462       fprintf (stderr, "test_grub_install_0: expected true, got false\n");
1463       return -1;
1464     }
1465   }
1466   return 0;
1467 }
1468
1469 static int test_zero_0 (void)
1470 {
1471   /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
1472   {
1473     char device[] = "/dev/sda";
1474     device[5] = devchar;
1475     int r;
1476     suppress_error = 0;
1477     r = guestfs_blockdev_setrw (g, device);
1478     if (r == -1)
1479       return -1;
1480   }
1481   {
1482     int r;
1483     suppress_error = 0;
1484     r = guestfs_umount_all (g);
1485     if (r == -1)
1486       return -1;
1487   }
1488   {
1489     int r;
1490     suppress_error = 0;
1491     r = guestfs_lvm_remove_all (g);
1492     if (r == -1)
1493       return -1;
1494   }
1495   {
1496     char device[] = "/dev/sda";
1497     device[5] = devchar;
1498     char lines_0[] = ",";
1499     char *lines[] = {
1500       lines_0,
1501       NULL
1502     };
1503     int r;
1504     suppress_error = 0;
1505     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1506     if (r == -1)
1507       return -1;
1508   }
1509   {
1510     char fstype[] = "ext2";
1511     char device[] = "/dev/sda1";
1512     device[5] = devchar;
1513     int r;
1514     suppress_error = 0;
1515     r = guestfs_mkfs (g, fstype, device);
1516     if (r == -1)
1517       return -1;
1518   }
1519   {
1520     char device[] = "/dev/sda1";
1521     device[5] = devchar;
1522     char mountpoint[] = "/";
1523     int r;
1524     suppress_error = 0;
1525     r = guestfs_mount (g, device, mountpoint);
1526     if (r == -1)
1527       return -1;
1528   }
1529   /* TestOutput for zero (0) */
1530   char expected[] = "data";
1531   {
1532     char pathordevice[] = "/dev/sda1";
1533     pathordevice[5] = devchar;
1534     int r;
1535     suppress_error = 0;
1536     r = guestfs_umount (g, pathordevice);
1537     if (r == -1)
1538       return -1;
1539   }
1540   {
1541     char device[] = "/dev/sda1";
1542     device[5] = devchar;
1543     int r;
1544     suppress_error = 0;
1545     r = guestfs_zero (g, device);
1546     if (r == -1)
1547       return -1;
1548   }
1549   {
1550     char path[] = "/dev/sda1";
1551     path[5] = devchar;
1552     char *r;
1553     suppress_error = 0;
1554     r = guestfs_file (g, path);
1555     if (r == NULL)
1556       return -1;
1557     if (strcmp (r, expected) != 0) {
1558       fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
1559       return -1;
1560     }
1561     free (r);
1562   }
1563   return 0;
1564 }
1565
1566 static int test_fsck_0 (void)
1567 {
1568   /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
1569   {
1570     char device[] = "/dev/sda";
1571     device[5] = devchar;
1572     int r;
1573     suppress_error = 0;
1574     r = guestfs_blockdev_setrw (g, device);
1575     if (r == -1)
1576       return -1;
1577   }
1578   {
1579     int r;
1580     suppress_error = 0;
1581     r = guestfs_umount_all (g);
1582     if (r == -1)
1583       return -1;
1584   }
1585   {
1586     int r;
1587     suppress_error = 0;
1588     r = guestfs_lvm_remove_all (g);
1589     if (r == -1)
1590       return -1;
1591   }
1592   {
1593     char device[] = "/dev/sda";
1594     device[5] = devchar;
1595     char lines_0[] = ",";
1596     char *lines[] = {
1597       lines_0,
1598       NULL
1599     };
1600     int r;
1601     suppress_error = 0;
1602     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1603     if (r == -1)
1604       return -1;
1605   }
1606   {
1607     char fstype[] = "ext2";
1608     char device[] = "/dev/sda1";
1609     device[5] = devchar;
1610     int r;
1611     suppress_error = 0;
1612     r = guestfs_mkfs (g, fstype, device);
1613     if (r == -1)
1614       return -1;
1615   }
1616   {
1617     char device[] = "/dev/sda1";
1618     device[5] = devchar;
1619     char mountpoint[] = "/";
1620     int r;
1621     suppress_error = 0;
1622     r = guestfs_mount (g, device, mountpoint);
1623     if (r == -1)
1624       return -1;
1625   }
1626   /* TestOutputInt for fsck (0) */
1627   {
1628     char pathordevice[] = "/dev/sda1";
1629     pathordevice[5] = devchar;
1630     int r;
1631     suppress_error = 0;
1632     r = guestfs_umount (g, pathordevice);
1633     if (r == -1)
1634       return -1;
1635   }
1636   {
1637     char fstype[] = "ext2";
1638     char device[] = "/dev/sda1";
1639     device[5] = devchar;
1640     int r;
1641     suppress_error = 0;
1642     r = guestfs_fsck (g, fstype, device);
1643     if (r == -1)
1644       return -1;
1645     if (r != 0) {
1646       fprintf (stderr, "test_fsck_0: expected 0 but got %d\n",               (int) r);
1647       return -1;
1648     }
1649   }
1650   return 0;
1651 }
1652
1653 static int test_fsck_1 (void)
1654 {
1655   /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
1656   {
1657     char device[] = "/dev/sda";
1658     device[5] = devchar;
1659     int r;
1660     suppress_error = 0;
1661     r = guestfs_blockdev_setrw (g, device);
1662     if (r == -1)
1663       return -1;
1664   }
1665   {
1666     int r;
1667     suppress_error = 0;
1668     r = guestfs_umount_all (g);
1669     if (r == -1)
1670       return -1;
1671   }
1672   {
1673     int r;
1674     suppress_error = 0;
1675     r = guestfs_lvm_remove_all (g);
1676     if (r == -1)
1677       return -1;
1678   }
1679   {
1680     char device[] = "/dev/sda";
1681     device[5] = devchar;
1682     char lines_0[] = ",";
1683     char *lines[] = {
1684       lines_0,
1685       NULL
1686     };
1687     int r;
1688     suppress_error = 0;
1689     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1690     if (r == -1)
1691       return -1;
1692   }
1693   {
1694     char fstype[] = "ext2";
1695     char device[] = "/dev/sda1";
1696     device[5] = devchar;
1697     int r;
1698     suppress_error = 0;
1699     r = guestfs_mkfs (g, fstype, device);
1700     if (r == -1)
1701       return -1;
1702   }
1703   {
1704     char device[] = "/dev/sda1";
1705     device[5] = devchar;
1706     char mountpoint[] = "/";
1707     int r;
1708     suppress_error = 0;
1709     r = guestfs_mount (g, device, mountpoint);
1710     if (r == -1)
1711       return -1;
1712   }
1713   /* TestOutputInt for fsck (1) */
1714   {
1715     char pathordevice[] = "/dev/sda1";
1716     pathordevice[5] = devchar;
1717     int r;
1718     suppress_error = 0;
1719     r = guestfs_umount (g, pathordevice);
1720     if (r == -1)
1721       return -1;
1722   }
1723   {
1724     char device[] = "/dev/sda1";
1725     device[5] = devchar;
1726     int r;
1727     suppress_error = 0;
1728     r = guestfs_zero (g, device);
1729     if (r == -1)
1730       return -1;
1731   }
1732   {
1733     char fstype[] = "ext2";
1734     char device[] = "/dev/sda1";
1735     device[5] = devchar;
1736     int r;
1737     suppress_error = 0;
1738     r = guestfs_fsck (g, fstype, device);
1739     if (r == -1)
1740       return -1;
1741     if (r != 8) {
1742       fprintf (stderr, "test_fsck_1: expected 8 but got %d\n",               (int) r);
1743       return -1;
1744     }
1745   }
1746   return 0;
1747 }
1748
1749 static int test_set_e2uuid_0 (void)
1750 {
1751   /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
1752   {
1753     char device[] = "/dev/sda";
1754     device[5] = devchar;
1755     int r;
1756     suppress_error = 0;
1757     r = guestfs_blockdev_setrw (g, device);
1758     if (r == -1)
1759       return -1;
1760   }
1761   {
1762     int r;
1763     suppress_error = 0;
1764     r = guestfs_umount_all (g);
1765     if (r == -1)
1766       return -1;
1767   }
1768   {
1769     int r;
1770     suppress_error = 0;
1771     r = guestfs_lvm_remove_all (g);
1772     if (r == -1)
1773       return -1;
1774   }
1775   {
1776     char device[] = "/dev/sda";
1777     device[5] = devchar;
1778     char lines_0[] = ",";
1779     char *lines[] = {
1780       lines_0,
1781       NULL
1782     };
1783     int r;
1784     suppress_error = 0;
1785     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1786     if (r == -1)
1787       return -1;
1788   }
1789   {
1790     char fstype[] = "ext2";
1791     char device[] = "/dev/sda1";
1792     device[5] = devchar;
1793     int r;
1794     suppress_error = 0;
1795     r = guestfs_mkfs (g, fstype, device);
1796     if (r == -1)
1797       return -1;
1798   }
1799   {
1800     char device[] = "/dev/sda1";
1801     device[5] = devchar;
1802     char mountpoint[] = "/";
1803     int r;
1804     suppress_error = 0;
1805     r = guestfs_mount (g, device, mountpoint);
1806     if (r == -1)
1807       return -1;
1808   }
1809   /* TestOutput for set_e2uuid (0) */
1810   char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1811   {
1812     char device[] = "/dev/sda1";
1813     device[5] = devchar;
1814     char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1815     int r;
1816     suppress_error = 0;
1817     r = guestfs_set_e2uuid (g, device, uuid);
1818     if (r == -1)
1819       return -1;
1820   }
1821   {
1822     char device[] = "/dev/sda1";
1823     device[5] = devchar;
1824     char *r;
1825     suppress_error = 0;
1826     r = guestfs_get_e2uuid (g, device);
1827     if (r == NULL)
1828       return -1;
1829     if (strcmp (r, expected) != 0) {
1830       fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
1831       return -1;
1832     }
1833     free (r);
1834   }
1835   return 0;
1836 }
1837
1838 static int test_set_e2uuid_1 (void)
1839 {
1840   /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
1841   {
1842     char device[] = "/dev/sda";
1843     device[5] = devchar;
1844     int r;
1845     suppress_error = 0;
1846     r = guestfs_blockdev_setrw (g, device);
1847     if (r == -1)
1848       return -1;
1849   }
1850   {
1851     int r;
1852     suppress_error = 0;
1853     r = guestfs_umount_all (g);
1854     if (r == -1)
1855       return -1;
1856   }
1857   {
1858     int r;
1859     suppress_error = 0;
1860     r = guestfs_lvm_remove_all (g);
1861     if (r == -1)
1862       return -1;
1863   }
1864   {
1865     char device[] = "/dev/sda";
1866     device[5] = devchar;
1867     char lines_0[] = ",";
1868     char *lines[] = {
1869       lines_0,
1870       NULL
1871     };
1872     int r;
1873     suppress_error = 0;
1874     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1875     if (r == -1)
1876       return -1;
1877   }
1878   {
1879     char fstype[] = "ext2";
1880     char device[] = "/dev/sda1";
1881     device[5] = devchar;
1882     int r;
1883     suppress_error = 0;
1884     r = guestfs_mkfs (g, fstype, device);
1885     if (r == -1)
1886       return -1;
1887   }
1888   {
1889     char device[] = "/dev/sda1";
1890     device[5] = devchar;
1891     char mountpoint[] = "/";
1892     int r;
1893     suppress_error = 0;
1894     r = guestfs_mount (g, device, mountpoint);
1895     if (r == -1)
1896       return -1;
1897   }
1898   /* TestOutput for set_e2uuid (1) */
1899   char expected[] = "";
1900   {
1901     char device[] = "/dev/sda1";
1902     device[5] = devchar;
1903     char uuid[] = "clear";
1904     int r;
1905     suppress_error = 0;
1906     r = guestfs_set_e2uuid (g, device, uuid);
1907     if (r == -1)
1908       return -1;
1909   }
1910   {
1911     char device[] = "/dev/sda1";
1912     device[5] = devchar;
1913     char *r;
1914     suppress_error = 0;
1915     r = guestfs_get_e2uuid (g, device);
1916     if (r == NULL)
1917       return -1;
1918     if (strcmp (r, expected) != 0) {
1919       fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
1920       return -1;
1921     }
1922     free (r);
1923   }
1924   return 0;
1925 }
1926
1927 static int test_set_e2uuid_2 (void)
1928 {
1929   /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
1930   {
1931     char device[] = "/dev/sda";
1932     device[5] = devchar;
1933     int r;
1934     suppress_error = 0;
1935     r = guestfs_blockdev_setrw (g, device);
1936     if (r == -1)
1937       return -1;
1938   }
1939   {
1940     int r;
1941     suppress_error = 0;
1942     r = guestfs_umount_all (g);
1943     if (r == -1)
1944       return -1;
1945   }
1946   {
1947     int r;
1948     suppress_error = 0;
1949     r = guestfs_lvm_remove_all (g);
1950     if (r == -1)
1951       return -1;
1952   }
1953   {
1954     char device[] = "/dev/sda";
1955     device[5] = devchar;
1956     char lines_0[] = ",";
1957     char *lines[] = {
1958       lines_0,
1959       NULL
1960     };
1961     int r;
1962     suppress_error = 0;
1963     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1964     if (r == -1)
1965       return -1;
1966   }
1967   {
1968     char fstype[] = "ext2";
1969     char device[] = "/dev/sda1";
1970     device[5] = devchar;
1971     int r;
1972     suppress_error = 0;
1973     r = guestfs_mkfs (g, fstype, device);
1974     if (r == -1)
1975       return -1;
1976   }
1977   {
1978     char device[] = "/dev/sda1";
1979     device[5] = devchar;
1980     char mountpoint[] = "/";
1981     int r;
1982     suppress_error = 0;
1983     r = guestfs_mount (g, device, mountpoint);
1984     if (r == -1)
1985       return -1;
1986   }
1987   /* TestRun for set_e2uuid (2) */
1988   {
1989     char device[] = "/dev/sda1";
1990     device[5] = devchar;
1991     char uuid[] = "random";
1992     int r;
1993     suppress_error = 0;
1994     r = guestfs_set_e2uuid (g, device, uuid);
1995     if (r == -1)
1996       return -1;
1997   }
1998   return 0;
1999 }
2000
2001 static int test_set_e2uuid_3 (void)
2002 {
2003   /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
2004   {
2005     char device[] = "/dev/sda";
2006     device[5] = devchar;
2007     int r;
2008     suppress_error = 0;
2009     r = guestfs_blockdev_setrw (g, device);
2010     if (r == -1)
2011       return -1;
2012   }
2013   {
2014     int r;
2015     suppress_error = 0;
2016     r = guestfs_umount_all (g);
2017     if (r == -1)
2018       return -1;
2019   }
2020   {
2021     int r;
2022     suppress_error = 0;
2023     r = guestfs_lvm_remove_all (g);
2024     if (r == -1)
2025       return -1;
2026   }
2027   {
2028     char device[] = "/dev/sda";
2029     device[5] = devchar;
2030     char lines_0[] = ",";
2031     char *lines[] = {
2032       lines_0,
2033       NULL
2034     };
2035     int r;
2036     suppress_error = 0;
2037     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2038     if (r == -1)
2039       return -1;
2040   }
2041   {
2042     char fstype[] = "ext2";
2043     char device[] = "/dev/sda1";
2044     device[5] = devchar;
2045     int r;
2046     suppress_error = 0;
2047     r = guestfs_mkfs (g, fstype, device);
2048     if (r == -1)
2049       return -1;
2050   }
2051   {
2052     char device[] = "/dev/sda1";
2053     device[5] = devchar;
2054     char mountpoint[] = "/";
2055     int r;
2056     suppress_error = 0;
2057     r = guestfs_mount (g, device, mountpoint);
2058     if (r == -1)
2059       return -1;
2060   }
2061   /* TestRun for set_e2uuid (3) */
2062   {
2063     char device[] = "/dev/sda1";
2064     device[5] = devchar;
2065     char uuid[] = "time";
2066     int r;
2067     suppress_error = 0;
2068     r = guestfs_set_e2uuid (g, device, uuid);
2069     if (r == -1)
2070       return -1;
2071   }
2072   return 0;
2073 }
2074
2075 static int test_set_e2label_0 (void)
2076 {
2077   /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
2078   {
2079     char device[] = "/dev/sda";
2080     device[5] = devchar;
2081     int r;
2082     suppress_error = 0;
2083     r = guestfs_blockdev_setrw (g, device);
2084     if (r == -1)
2085       return -1;
2086   }
2087   {
2088     int r;
2089     suppress_error = 0;
2090     r = guestfs_umount_all (g);
2091     if (r == -1)
2092       return -1;
2093   }
2094   {
2095     int r;
2096     suppress_error = 0;
2097     r = guestfs_lvm_remove_all (g);
2098     if (r == -1)
2099       return -1;
2100   }
2101   {
2102     char device[] = "/dev/sda";
2103     device[5] = devchar;
2104     char lines_0[] = ",";
2105     char *lines[] = {
2106       lines_0,
2107       NULL
2108     };
2109     int r;
2110     suppress_error = 0;
2111     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2112     if (r == -1)
2113       return -1;
2114   }
2115   {
2116     char fstype[] = "ext2";
2117     char device[] = "/dev/sda1";
2118     device[5] = devchar;
2119     int r;
2120     suppress_error = 0;
2121     r = guestfs_mkfs (g, fstype, device);
2122     if (r == -1)
2123       return -1;
2124   }
2125   {
2126     char device[] = "/dev/sda1";
2127     device[5] = devchar;
2128     char mountpoint[] = "/";
2129     int r;
2130     suppress_error = 0;
2131     r = guestfs_mount (g, device, mountpoint);
2132     if (r == -1)
2133       return -1;
2134   }
2135   /* TestOutput for set_e2label (0) */
2136   char expected[] = "testlabel";
2137   {
2138     char device[] = "/dev/sda1";
2139     device[5] = devchar;
2140     char label[] = "testlabel";
2141     int r;
2142     suppress_error = 0;
2143     r = guestfs_set_e2label (g, device, label);
2144     if (r == -1)
2145       return -1;
2146   }
2147   {
2148     char device[] = "/dev/sda1";
2149     device[5] = devchar;
2150     char *r;
2151     suppress_error = 0;
2152     r = guestfs_get_e2label (g, device);
2153     if (r == NULL)
2154       return -1;
2155     if (strcmp (r, expected) != 0) {
2156       fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
2157       return -1;
2158     }
2159     free (r);
2160   }
2161   return 0;
2162 }
2163
2164 static int test_pvremove_0 (void)
2165 {
2166   /* InitEmpty for pvremove (0) */
2167   {
2168     char device[] = "/dev/sda";
2169     device[5] = devchar;
2170     int r;
2171     suppress_error = 0;
2172     r = guestfs_blockdev_setrw (g, device);
2173     if (r == -1)
2174       return -1;
2175   }
2176   {
2177     int r;
2178     suppress_error = 0;
2179     r = guestfs_umount_all (g);
2180     if (r == -1)
2181       return -1;
2182   }
2183   {
2184     int r;
2185     suppress_error = 0;
2186     r = guestfs_lvm_remove_all (g);
2187     if (r == -1)
2188       return -1;
2189   }
2190   /* TestOutputList for pvremove (0) */
2191   {
2192     char device[] = "/dev/sda";
2193     device[5] = devchar;
2194     int r;
2195     suppress_error = 0;
2196     r = guestfs_pvcreate (g, device);
2197     if (r == -1)
2198       return -1;
2199   }
2200   {
2201     char volgroup[] = "VG";
2202     char physvols_0[] = "/dev/sda";
2203     physvols_0[5] = devchar;
2204     char *physvols[] = {
2205       physvols_0,
2206       NULL
2207     };
2208     int r;
2209     suppress_error = 0;
2210     r = guestfs_vgcreate (g, volgroup, physvols);
2211     if (r == -1)
2212       return -1;
2213   }
2214   {
2215     char logvol[] = "LV1";
2216     char volgroup[] = "VG";
2217     int r;
2218     suppress_error = 0;
2219     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2220     if (r == -1)
2221       return -1;
2222   }
2223   {
2224     char logvol[] = "LV2";
2225     char volgroup[] = "VG";
2226     int r;
2227     suppress_error = 0;
2228     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2229     if (r == -1)
2230       return -1;
2231   }
2232   {
2233     char vgname[] = "VG";
2234     int r;
2235     suppress_error = 0;
2236     r = guestfs_vgremove (g, vgname);
2237     if (r == -1)
2238       return -1;
2239   }
2240   {
2241     char device[] = "/dev/sda";
2242     device[5] = devchar;
2243     int r;
2244     suppress_error = 0;
2245     r = guestfs_pvremove (g, device);
2246     if (r == -1)
2247       return -1;
2248   }
2249   {
2250     char **r;
2251     int i;
2252     suppress_error = 0;
2253     r = guestfs_lvs (g);
2254     if (r == NULL)
2255       return -1;
2256     if (r[0] != NULL) {
2257       fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
2258       print_strings (r);
2259       return -1;
2260     }
2261     for (i = 0; r[i] != NULL; ++i)
2262       free (r[i]);
2263     free (r);
2264   }
2265   return 0;
2266 }
2267
2268 static int test_pvremove_1 (void)
2269 {
2270   /* InitEmpty for pvremove (1) */
2271   {
2272     char device[] = "/dev/sda";
2273     device[5] = devchar;
2274     int r;
2275     suppress_error = 0;
2276     r = guestfs_blockdev_setrw (g, device);
2277     if (r == -1)
2278       return -1;
2279   }
2280   {
2281     int r;
2282     suppress_error = 0;
2283     r = guestfs_umount_all (g);
2284     if (r == -1)
2285       return -1;
2286   }
2287   {
2288     int r;
2289     suppress_error = 0;
2290     r = guestfs_lvm_remove_all (g);
2291     if (r == -1)
2292       return -1;
2293   }
2294   /* TestOutputList for pvremove (1) */
2295   {
2296     char device[] = "/dev/sda";
2297     device[5] = devchar;
2298     int r;
2299     suppress_error = 0;
2300     r = guestfs_pvcreate (g, device);
2301     if (r == -1)
2302       return -1;
2303   }
2304   {
2305     char volgroup[] = "VG";
2306     char physvols_0[] = "/dev/sda";
2307     physvols_0[5] = devchar;
2308     char *physvols[] = {
2309       physvols_0,
2310       NULL
2311     };
2312     int r;
2313     suppress_error = 0;
2314     r = guestfs_vgcreate (g, volgroup, physvols);
2315     if (r == -1)
2316       return -1;
2317   }
2318   {
2319     char logvol[] = "LV1";
2320     char volgroup[] = "VG";
2321     int r;
2322     suppress_error = 0;
2323     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2324     if (r == -1)
2325       return -1;
2326   }
2327   {
2328     char logvol[] = "LV2";
2329     char volgroup[] = "VG";
2330     int r;
2331     suppress_error = 0;
2332     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2333     if (r == -1)
2334       return -1;
2335   }
2336   {
2337     char vgname[] = "VG";
2338     int r;
2339     suppress_error = 0;
2340     r = guestfs_vgremove (g, vgname);
2341     if (r == -1)
2342       return -1;
2343   }
2344   {
2345     char device[] = "/dev/sda";
2346     device[5] = devchar;
2347     int r;
2348     suppress_error = 0;
2349     r = guestfs_pvremove (g, device);
2350     if (r == -1)
2351       return -1;
2352   }
2353   {
2354     char **r;
2355     int i;
2356     suppress_error = 0;
2357     r = guestfs_vgs (g);
2358     if (r == NULL)
2359       return -1;
2360     if (r[0] != NULL) {
2361       fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
2362       print_strings (r);
2363       return -1;
2364     }
2365     for (i = 0; r[i] != NULL; ++i)
2366       free (r[i]);
2367     free (r);
2368   }
2369   return 0;
2370 }
2371
2372 static int test_pvremove_2 (void)
2373 {
2374   /* InitEmpty for pvremove (2) */
2375   {
2376     char device[] = "/dev/sda";
2377     device[5] = devchar;
2378     int r;
2379     suppress_error = 0;
2380     r = guestfs_blockdev_setrw (g, device);
2381     if (r == -1)
2382       return -1;
2383   }
2384   {
2385     int r;
2386     suppress_error = 0;
2387     r = guestfs_umount_all (g);
2388     if (r == -1)
2389       return -1;
2390   }
2391   {
2392     int r;
2393     suppress_error = 0;
2394     r = guestfs_lvm_remove_all (g);
2395     if (r == -1)
2396       return -1;
2397   }
2398   /* TestOutputList for pvremove (2) */
2399   {
2400     char device[] = "/dev/sda";
2401     device[5] = devchar;
2402     int r;
2403     suppress_error = 0;
2404     r = guestfs_pvcreate (g, device);
2405     if (r == -1)
2406       return -1;
2407   }
2408   {
2409     char volgroup[] = "VG";
2410     char physvols_0[] = "/dev/sda";
2411     physvols_0[5] = devchar;
2412     char *physvols[] = {
2413       physvols_0,
2414       NULL
2415     };
2416     int r;
2417     suppress_error = 0;
2418     r = guestfs_vgcreate (g, volgroup, physvols);
2419     if (r == -1)
2420       return -1;
2421   }
2422   {
2423     char logvol[] = "LV1";
2424     char volgroup[] = "VG";
2425     int r;
2426     suppress_error = 0;
2427     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2428     if (r == -1)
2429       return -1;
2430   }
2431   {
2432     char logvol[] = "LV2";
2433     char volgroup[] = "VG";
2434     int r;
2435     suppress_error = 0;
2436     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2437     if (r == -1)
2438       return -1;
2439   }
2440   {
2441     char vgname[] = "VG";
2442     int r;
2443     suppress_error = 0;
2444     r = guestfs_vgremove (g, vgname);
2445     if (r == -1)
2446       return -1;
2447   }
2448   {
2449     char device[] = "/dev/sda";
2450     device[5] = devchar;
2451     int r;
2452     suppress_error = 0;
2453     r = guestfs_pvremove (g, device);
2454     if (r == -1)
2455       return -1;
2456   }
2457   {
2458     char **r;
2459     int i;
2460     suppress_error = 0;
2461     r = guestfs_pvs (g);
2462     if (r == NULL)
2463       return -1;
2464     if (r[0] != NULL) {
2465       fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
2466       print_strings (r);
2467       return -1;
2468     }
2469     for (i = 0; r[i] != NULL; ++i)
2470       free (r[i]);
2471     free (r);
2472   }
2473   return 0;
2474 }
2475
2476 static int test_vgremove_0 (void)
2477 {
2478   /* InitEmpty for vgremove (0) */
2479   {
2480     char device[] = "/dev/sda";
2481     device[5] = devchar;
2482     int r;
2483     suppress_error = 0;
2484     r = guestfs_blockdev_setrw (g, device);
2485     if (r == -1)
2486       return -1;
2487   }
2488   {
2489     int r;
2490     suppress_error = 0;
2491     r = guestfs_umount_all (g);
2492     if (r == -1)
2493       return -1;
2494   }
2495   {
2496     int r;
2497     suppress_error = 0;
2498     r = guestfs_lvm_remove_all (g);
2499     if (r == -1)
2500       return -1;
2501   }
2502   /* TestOutputList for vgremove (0) */
2503   {
2504     char device[] = "/dev/sda";
2505     device[5] = devchar;
2506     int r;
2507     suppress_error = 0;
2508     r = guestfs_pvcreate (g, device);
2509     if (r == -1)
2510       return -1;
2511   }
2512   {
2513     char volgroup[] = "VG";
2514     char physvols_0[] = "/dev/sda";
2515     physvols_0[5] = devchar;
2516     char *physvols[] = {
2517       physvols_0,
2518       NULL
2519     };
2520     int r;
2521     suppress_error = 0;
2522     r = guestfs_vgcreate (g, volgroup, physvols);
2523     if (r == -1)
2524       return -1;
2525   }
2526   {
2527     char logvol[] = "LV1";
2528     char volgroup[] = "VG";
2529     int r;
2530     suppress_error = 0;
2531     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2532     if (r == -1)
2533       return -1;
2534   }
2535   {
2536     char logvol[] = "LV2";
2537     char volgroup[] = "VG";
2538     int r;
2539     suppress_error = 0;
2540     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2541     if (r == -1)
2542       return -1;
2543   }
2544   {
2545     char vgname[] = "VG";
2546     int r;
2547     suppress_error = 0;
2548     r = guestfs_vgremove (g, vgname);
2549     if (r == -1)
2550       return -1;
2551   }
2552   {
2553     char **r;
2554     int i;
2555     suppress_error = 0;
2556     r = guestfs_lvs (g);
2557     if (r == NULL)
2558       return -1;
2559     if (r[0] != NULL) {
2560       fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
2561       print_strings (r);
2562       return -1;
2563     }
2564     for (i = 0; r[i] != NULL; ++i)
2565       free (r[i]);
2566     free (r);
2567   }
2568   return 0;
2569 }
2570
2571 static int test_vgremove_1 (void)
2572 {
2573   /* InitEmpty for vgremove (1) */
2574   {
2575     char device[] = "/dev/sda";
2576     device[5] = devchar;
2577     int r;
2578     suppress_error = 0;
2579     r = guestfs_blockdev_setrw (g, device);
2580     if (r == -1)
2581       return -1;
2582   }
2583   {
2584     int r;
2585     suppress_error = 0;
2586     r = guestfs_umount_all (g);
2587     if (r == -1)
2588       return -1;
2589   }
2590   {
2591     int r;
2592     suppress_error = 0;
2593     r = guestfs_lvm_remove_all (g);
2594     if (r == -1)
2595       return -1;
2596   }
2597   /* TestOutputList for vgremove (1) */
2598   {
2599     char device[] = "/dev/sda";
2600     device[5] = devchar;
2601     int r;
2602     suppress_error = 0;
2603     r = guestfs_pvcreate (g, device);
2604     if (r == -1)
2605       return -1;
2606   }
2607   {
2608     char volgroup[] = "VG";
2609     char physvols_0[] = "/dev/sda";
2610     physvols_0[5] = devchar;
2611     char *physvols[] = {
2612       physvols_0,
2613       NULL
2614     };
2615     int r;
2616     suppress_error = 0;
2617     r = guestfs_vgcreate (g, volgroup, physvols);
2618     if (r == -1)
2619       return -1;
2620   }
2621   {
2622     char logvol[] = "LV1";
2623     char volgroup[] = "VG";
2624     int r;
2625     suppress_error = 0;
2626     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2627     if (r == -1)
2628       return -1;
2629   }
2630   {
2631     char logvol[] = "LV2";
2632     char volgroup[] = "VG";
2633     int r;
2634     suppress_error = 0;
2635     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2636     if (r == -1)
2637       return -1;
2638   }
2639   {
2640     char vgname[] = "VG";
2641     int r;
2642     suppress_error = 0;
2643     r = guestfs_vgremove (g, vgname);
2644     if (r == -1)
2645       return -1;
2646   }
2647   {
2648     char **r;
2649     int i;
2650     suppress_error = 0;
2651     r = guestfs_vgs (g);
2652     if (r == NULL)
2653       return -1;
2654     if (r[0] != NULL) {
2655       fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
2656       print_strings (r);
2657       return -1;
2658     }
2659     for (i = 0; r[i] != NULL; ++i)
2660       free (r[i]);
2661     free (r);
2662   }
2663   return 0;
2664 }
2665
2666 static int test_lvremove_0 (void)
2667 {
2668   /* InitEmpty for lvremove (0) */
2669   {
2670     char device[] = "/dev/sda";
2671     device[5] = devchar;
2672     int r;
2673     suppress_error = 0;
2674     r = guestfs_blockdev_setrw (g, device);
2675     if (r == -1)
2676       return -1;
2677   }
2678   {
2679     int r;
2680     suppress_error = 0;
2681     r = guestfs_umount_all (g);
2682     if (r == -1)
2683       return -1;
2684   }
2685   {
2686     int r;
2687     suppress_error = 0;
2688     r = guestfs_lvm_remove_all (g);
2689     if (r == -1)
2690       return -1;
2691   }
2692   /* TestOutputList for lvremove (0) */
2693   {
2694     char device[] = "/dev/sda";
2695     device[5] = devchar;
2696     int r;
2697     suppress_error = 0;
2698     r = guestfs_pvcreate (g, device);
2699     if (r == -1)
2700       return -1;
2701   }
2702   {
2703     char volgroup[] = "VG";
2704     char physvols_0[] = "/dev/sda";
2705     physvols_0[5] = devchar;
2706     char *physvols[] = {
2707       physvols_0,
2708       NULL
2709     };
2710     int r;
2711     suppress_error = 0;
2712     r = guestfs_vgcreate (g, volgroup, physvols);
2713     if (r == -1)
2714       return -1;
2715   }
2716   {
2717     char logvol[] = "LV1";
2718     char volgroup[] = "VG";
2719     int r;
2720     suppress_error = 0;
2721     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2722     if (r == -1)
2723       return -1;
2724   }
2725   {
2726     char logvol[] = "LV2";
2727     char volgroup[] = "VG";
2728     int r;
2729     suppress_error = 0;
2730     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2731     if (r == -1)
2732       return -1;
2733   }
2734   {
2735     char device[] = "/dev/VG/LV1";
2736     int r;
2737     suppress_error = 0;
2738     r = guestfs_lvremove (g, device);
2739     if (r == -1)
2740       return -1;
2741   }
2742   {
2743     char **r;
2744     int i;
2745     suppress_error = 0;
2746     r = guestfs_lvs (g);
2747     if (r == NULL)
2748       return -1;
2749     if (!r[0]) {
2750       fprintf (stderr, "test_lvremove_0: short list returned from command\n");
2751       print_strings (r);
2752       return -1;
2753     }
2754     {
2755       char expected[] = "/dev/VG/LV2";
2756       if (strcmp (r[0], expected) != 0) {
2757         fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2758         return -1;
2759       }
2760     }
2761     if (r[1] != NULL) {
2762       fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
2763       print_strings (r);
2764       return -1;
2765     }
2766     for (i = 0; r[i] != NULL; ++i)
2767       free (r[i]);
2768     free (r);
2769   }
2770   return 0;
2771 }
2772
2773 static int test_lvremove_1 (void)
2774 {
2775   /* InitEmpty for lvremove (1) */
2776   {
2777     char device[] = "/dev/sda";
2778     device[5] = devchar;
2779     int r;
2780     suppress_error = 0;
2781     r = guestfs_blockdev_setrw (g, device);
2782     if (r == -1)
2783       return -1;
2784   }
2785   {
2786     int r;
2787     suppress_error = 0;
2788     r = guestfs_umount_all (g);
2789     if (r == -1)
2790       return -1;
2791   }
2792   {
2793     int r;
2794     suppress_error = 0;
2795     r = guestfs_lvm_remove_all (g);
2796     if (r == -1)
2797       return -1;
2798   }
2799   /* TestOutputList for lvremove (1) */
2800   {
2801     char device[] = "/dev/sda";
2802     device[5] = devchar;
2803     int r;
2804     suppress_error = 0;
2805     r = guestfs_pvcreate (g, device);
2806     if (r == -1)
2807       return -1;
2808   }
2809   {
2810     char volgroup[] = "VG";
2811     char physvols_0[] = "/dev/sda";
2812     physvols_0[5] = devchar;
2813     char *physvols[] = {
2814       physvols_0,
2815       NULL
2816     };
2817     int r;
2818     suppress_error = 0;
2819     r = guestfs_vgcreate (g, volgroup, physvols);
2820     if (r == -1)
2821       return -1;
2822   }
2823   {
2824     char logvol[] = "LV1";
2825     char volgroup[] = "VG";
2826     int r;
2827     suppress_error = 0;
2828     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2829     if (r == -1)
2830       return -1;
2831   }
2832   {
2833     char logvol[] = "LV2";
2834     char volgroup[] = "VG";
2835     int r;
2836     suppress_error = 0;
2837     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2838     if (r == -1)
2839       return -1;
2840   }
2841   {
2842     char device[] = "/dev/VG";
2843     int r;
2844     suppress_error = 0;
2845     r = guestfs_lvremove (g, device);
2846     if (r == -1)
2847       return -1;
2848   }
2849   {
2850     char **r;
2851     int i;
2852     suppress_error = 0;
2853     r = guestfs_lvs (g);
2854     if (r == NULL)
2855       return -1;
2856     if (r[0] != NULL) {
2857       fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
2858       print_strings (r);
2859       return -1;
2860     }
2861     for (i = 0; r[i] != NULL; ++i)
2862       free (r[i]);
2863     free (r);
2864   }
2865   return 0;
2866 }
2867
2868 static int test_lvremove_2 (void)
2869 {
2870   /* InitEmpty for lvremove (2) */
2871   {
2872     char device[] = "/dev/sda";
2873     device[5] = devchar;
2874     int r;
2875     suppress_error = 0;
2876     r = guestfs_blockdev_setrw (g, device);
2877     if (r == -1)
2878       return -1;
2879   }
2880   {
2881     int r;
2882     suppress_error = 0;
2883     r = guestfs_umount_all (g);
2884     if (r == -1)
2885       return -1;
2886   }
2887   {
2888     int r;
2889     suppress_error = 0;
2890     r = guestfs_lvm_remove_all (g);
2891     if (r == -1)
2892       return -1;
2893   }
2894   /* TestOutputList for lvremove (2) */
2895   {
2896     char device[] = "/dev/sda";
2897     device[5] = devchar;
2898     int r;
2899     suppress_error = 0;
2900     r = guestfs_pvcreate (g, device);
2901     if (r == -1)
2902       return -1;
2903   }
2904   {
2905     char volgroup[] = "VG";
2906     char physvols_0[] = "/dev/sda";
2907     physvols_0[5] = devchar;
2908     char *physvols[] = {
2909       physvols_0,
2910       NULL
2911     };
2912     int r;
2913     suppress_error = 0;
2914     r = guestfs_vgcreate (g, volgroup, physvols);
2915     if (r == -1)
2916       return -1;
2917   }
2918   {
2919     char logvol[] = "LV1";
2920     char volgroup[] = "VG";
2921     int r;
2922     suppress_error = 0;
2923     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2924     if (r == -1)
2925       return -1;
2926   }
2927   {
2928     char logvol[] = "LV2";
2929     char volgroup[] = "VG";
2930     int r;
2931     suppress_error = 0;
2932     r = guestfs_lvcreate (g, logvol, volgroup, 50);
2933     if (r == -1)
2934       return -1;
2935   }
2936   {
2937     char device[] = "/dev/VG";
2938     int r;
2939     suppress_error = 0;
2940     r = guestfs_lvremove (g, device);
2941     if (r == -1)
2942       return -1;
2943   }
2944   {
2945     char **r;
2946     int i;
2947     suppress_error = 0;
2948     r = guestfs_vgs (g);
2949     if (r == NULL)
2950       return -1;
2951     if (!r[0]) {
2952       fprintf (stderr, "test_lvremove_2: short list returned from command\n");
2953       print_strings (r);
2954       return -1;
2955     }
2956     {
2957       char expected[] = "VG";
2958       if (strcmp (r[0], expected) != 0) {
2959         fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2960         return -1;
2961       }
2962     }
2963     if (r[1] != NULL) {
2964       fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
2965       print_strings (r);
2966       return -1;
2967     }
2968     for (i = 0; r[i] != NULL; ++i)
2969       free (r[i]);
2970     free (r);
2971   }
2972   return 0;
2973 }
2974
2975 static int test_mount_ro_0 (void)
2976 {
2977   /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
2978   {
2979     char device[] = "/dev/sda";
2980     device[5] = devchar;
2981     int r;
2982     suppress_error = 0;
2983     r = guestfs_blockdev_setrw (g, device);
2984     if (r == -1)
2985       return -1;
2986   }
2987   {
2988     int r;
2989     suppress_error = 0;
2990     r = guestfs_umount_all (g);
2991     if (r == -1)
2992       return -1;
2993   }
2994   {
2995     int r;
2996     suppress_error = 0;
2997     r = guestfs_lvm_remove_all (g);
2998     if (r == -1)
2999       return -1;
3000   }
3001   {
3002     char device[] = "/dev/sda";
3003     device[5] = devchar;
3004     char lines_0[] = ",";
3005     char *lines[] = {
3006       lines_0,
3007       NULL
3008     };
3009     int r;
3010     suppress_error = 0;
3011     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3012     if (r == -1)
3013       return -1;
3014   }
3015   {
3016     char fstype[] = "ext2";
3017     char device[] = "/dev/sda1";
3018     device[5] = devchar;
3019     int r;
3020     suppress_error = 0;
3021     r = guestfs_mkfs (g, fstype, device);
3022     if (r == -1)
3023       return -1;
3024   }
3025   {
3026     char device[] = "/dev/sda1";
3027     device[5] = devchar;
3028     char mountpoint[] = "/";
3029     int r;
3030     suppress_error = 0;
3031     r = guestfs_mount (g, device, mountpoint);
3032     if (r == -1)
3033       return -1;
3034   }
3035   /* TestLastFail for mount_ro (0) */
3036   {
3037     char pathordevice[] = "/";
3038     int r;
3039     suppress_error = 0;
3040     r = guestfs_umount (g, pathordevice);
3041     if (r == -1)
3042       return -1;
3043   }
3044   {
3045     char device[] = "/dev/sda1";
3046     device[5] = devchar;
3047     char mountpoint[] = "/";
3048     int r;
3049     suppress_error = 0;
3050     r = guestfs_mount_ro (g, device, mountpoint);
3051     if (r == -1)
3052       return -1;
3053   }
3054   {
3055     char path[] = "/new";
3056     int r;
3057     suppress_error = 1;
3058     r = guestfs_touch (g, path);
3059     if (r != -1)
3060       return -1;
3061   }
3062   return 0;
3063 }
3064
3065 static int test_mount_ro_1 (void)
3066 {
3067   /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
3068   {
3069     char device[] = "/dev/sda";
3070     device[5] = devchar;
3071     int r;
3072     suppress_error = 0;
3073     r = guestfs_blockdev_setrw (g, device);
3074     if (r == -1)
3075       return -1;
3076   }
3077   {
3078     int r;
3079     suppress_error = 0;
3080     r = guestfs_umount_all (g);
3081     if (r == -1)
3082       return -1;
3083   }
3084   {
3085     int r;
3086     suppress_error = 0;
3087     r = guestfs_lvm_remove_all (g);
3088     if (r == -1)
3089       return -1;
3090   }
3091   {
3092     char device[] = "/dev/sda";
3093     device[5] = devchar;
3094     char lines_0[] = ",";
3095     char *lines[] = {
3096       lines_0,
3097       NULL
3098     };
3099     int r;
3100     suppress_error = 0;
3101     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3102     if (r == -1)
3103       return -1;
3104   }
3105   {
3106     char fstype[] = "ext2";
3107     char device[] = "/dev/sda1";
3108     device[5] = devchar;
3109     int r;
3110     suppress_error = 0;
3111     r = guestfs_mkfs (g, fstype, device);
3112     if (r == -1)
3113       return -1;
3114   }
3115   {
3116     char device[] = "/dev/sda1";
3117     device[5] = devchar;
3118     char mountpoint[] = "/";
3119     int r;
3120     suppress_error = 0;
3121     r = guestfs_mount (g, device, mountpoint);
3122     if (r == -1)
3123       return -1;
3124   }
3125   /* TestOutput for mount_ro (1) */
3126   char expected[] = "data";
3127   {
3128     char path[] = "/new";
3129     char content[] = "data";
3130     int r;
3131     suppress_error = 0;
3132     r = guestfs_write_file (g, path, content, 0);
3133     if (r == -1)
3134       return -1;
3135   }
3136   {
3137     char pathordevice[] = "/";
3138     int r;
3139     suppress_error = 0;
3140     r = guestfs_umount (g, pathordevice);
3141     if (r == -1)
3142       return -1;
3143   }
3144   {
3145     char device[] = "/dev/sda1";
3146     device[5] = devchar;
3147     char mountpoint[] = "/";
3148     int r;
3149     suppress_error = 0;
3150     r = guestfs_mount_ro (g, device, mountpoint);
3151     if (r == -1)
3152       return -1;
3153   }
3154   {
3155     char path[] = "/new";
3156     char *r;
3157     suppress_error = 0;
3158     r = guestfs_cat (g, path);
3159     if (r == NULL)
3160       return -1;
3161     if (strcmp (r, expected) != 0) {
3162       fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
3163       return -1;
3164     }
3165     free (r);
3166   }
3167   return 0;
3168 }
3169
3170 static int test_tgz_in_0 (void)
3171 {
3172   /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
3173   {
3174     char device[] = "/dev/sda";
3175     device[5] = devchar;
3176     int r;
3177     suppress_error = 0;
3178     r = guestfs_blockdev_setrw (g, device);
3179     if (r == -1)
3180       return -1;
3181   }
3182   {
3183     int r;
3184     suppress_error = 0;
3185     r = guestfs_umount_all (g);
3186     if (r == -1)
3187       return -1;
3188   }
3189   {
3190     int r;
3191     suppress_error = 0;
3192     r = guestfs_lvm_remove_all (g);
3193     if (r == -1)
3194       return -1;
3195   }
3196   {
3197     char device[] = "/dev/sda";
3198     device[5] = devchar;
3199     char lines_0[] = ",";
3200     char *lines[] = {
3201       lines_0,
3202       NULL
3203     };
3204     int r;
3205     suppress_error = 0;
3206     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3207     if (r == -1)
3208       return -1;
3209   }
3210   {
3211     char fstype[] = "ext2";
3212     char device[] = "/dev/sda1";
3213     device[5] = devchar;
3214     int r;
3215     suppress_error = 0;
3216     r = guestfs_mkfs (g, fstype, device);
3217     if (r == -1)
3218       return -1;
3219   }
3220   {
3221     char device[] = "/dev/sda1";
3222     device[5] = devchar;
3223     char mountpoint[] = "/";
3224     int r;
3225     suppress_error = 0;
3226     r = guestfs_mount (g, device, mountpoint);
3227     if (r == -1)
3228       return -1;
3229   }
3230   /* TestOutput for tgz_in (0) */
3231   char expected[] = "hello\n";
3232   {
3233     char directory[] = "/";
3234     int r;
3235     suppress_error = 0;
3236     r = guestfs_tgz_in (g, "images/helloworld.tar.gz", directory);
3237     if (r == -1)
3238       return -1;
3239   }
3240   {
3241     char path[] = "/hello";
3242     char *r;
3243     suppress_error = 0;
3244     r = guestfs_cat (g, path);
3245     if (r == NULL)
3246       return -1;
3247     if (strcmp (r, expected) != 0) {
3248       fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3249       return -1;
3250     }
3251     free (r);
3252   }
3253   return 0;
3254 }
3255
3256 static int test_tar_in_0 (void)
3257 {
3258   /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
3259   {
3260     char device[] = "/dev/sda";
3261     device[5] = devchar;
3262     int r;
3263     suppress_error = 0;
3264     r = guestfs_blockdev_setrw (g, device);
3265     if (r == -1)
3266       return -1;
3267   }
3268   {
3269     int r;
3270     suppress_error = 0;
3271     r = guestfs_umount_all (g);
3272     if (r == -1)
3273       return -1;
3274   }
3275   {
3276     int r;
3277     suppress_error = 0;
3278     r = guestfs_lvm_remove_all (g);
3279     if (r == -1)
3280       return -1;
3281   }
3282   {
3283     char device[] = "/dev/sda";
3284     device[5] = devchar;
3285     char lines_0[] = ",";
3286     char *lines[] = {
3287       lines_0,
3288       NULL
3289     };
3290     int r;
3291     suppress_error = 0;
3292     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3293     if (r == -1)
3294       return -1;
3295   }
3296   {
3297     char fstype[] = "ext2";
3298     char device[] = "/dev/sda1";
3299     device[5] = devchar;
3300     int r;
3301     suppress_error = 0;
3302     r = guestfs_mkfs (g, fstype, device);
3303     if (r == -1)
3304       return -1;
3305   }
3306   {
3307     char device[] = "/dev/sda1";
3308     device[5] = devchar;
3309     char mountpoint[] = "/";
3310     int r;
3311     suppress_error = 0;
3312     r = guestfs_mount (g, device, mountpoint);
3313     if (r == -1)
3314       return -1;
3315   }
3316   /* TestOutput for tar_in (0) */
3317   char expected[] = "hello\n";
3318   {
3319     char directory[] = "/";
3320     int r;
3321     suppress_error = 0;
3322     r = guestfs_tar_in (g, "images/helloworld.tar", directory);
3323     if (r == -1)
3324       return -1;
3325   }
3326   {
3327     char path[] = "/hello";
3328     char *r;
3329     suppress_error = 0;
3330     r = guestfs_cat (g, path);
3331     if (r == NULL)
3332       return -1;
3333     if (strcmp (r, expected) != 0) {
3334       fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3335       return -1;
3336     }
3337     free (r);
3338   }
3339   return 0;
3340 }
3341
3342 static int test_checksum_0 (void)
3343 {
3344   /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
3345   {
3346     char device[] = "/dev/sda";
3347     device[5] = devchar;
3348     int r;
3349     suppress_error = 0;
3350     r = guestfs_blockdev_setrw (g, device);
3351     if (r == -1)
3352       return -1;
3353   }
3354   {
3355     int r;
3356     suppress_error = 0;
3357     r = guestfs_umount_all (g);
3358     if (r == -1)
3359       return -1;
3360   }
3361   {
3362     int r;
3363     suppress_error = 0;
3364     r = guestfs_lvm_remove_all (g);
3365     if (r == -1)
3366       return -1;
3367   }
3368   {
3369     char device[] = "/dev/sda";
3370     device[5] = devchar;
3371     char lines_0[] = ",";
3372     char *lines[] = {
3373       lines_0,
3374       NULL
3375     };
3376     int r;
3377     suppress_error = 0;
3378     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3379     if (r == -1)
3380       return -1;
3381   }
3382   {
3383     char fstype[] = "ext2";
3384     char device[] = "/dev/sda1";
3385     device[5] = devchar;
3386     int r;
3387     suppress_error = 0;
3388     r = guestfs_mkfs (g, fstype, device);
3389     if (r == -1)
3390       return -1;
3391   }
3392   {
3393     char device[] = "/dev/sda1";
3394     device[5] = devchar;
3395     char mountpoint[] = "/";
3396     int r;
3397     suppress_error = 0;
3398     r = guestfs_mount (g, device, mountpoint);
3399     if (r == -1)
3400       return -1;
3401   }
3402   /* TestOutput for checksum (0) */
3403   char expected[] = "935282863";
3404   {
3405     char path[] = "/new";
3406     char content[] = "test\n";
3407     int r;
3408     suppress_error = 0;
3409     r = guestfs_write_file (g, path, content, 0);
3410     if (r == -1)
3411       return -1;
3412   }
3413   {
3414     char csumtype[] = "crc";
3415     char path[] = "/new";
3416     char *r;
3417     suppress_error = 0;
3418     r = guestfs_checksum (g, csumtype, path);
3419     if (r == NULL)
3420       return -1;
3421     if (strcmp (r, expected) != 0) {
3422       fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
3423       return -1;
3424     }
3425     free (r);
3426   }
3427   return 0;
3428 }
3429
3430 static int test_checksum_1 (void)
3431 {
3432   /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
3433   {
3434     char device[] = "/dev/sda";
3435     device[5] = devchar;
3436     int r;
3437     suppress_error = 0;
3438     r = guestfs_blockdev_setrw (g, device);
3439     if (r == -1)
3440       return -1;
3441   }
3442   {
3443     int r;
3444     suppress_error = 0;
3445     r = guestfs_umount_all (g);
3446     if (r == -1)
3447       return -1;
3448   }
3449   {
3450     int r;
3451     suppress_error = 0;
3452     r = guestfs_lvm_remove_all (g);
3453     if (r == -1)
3454       return -1;
3455   }
3456   {
3457     char device[] = "/dev/sda";
3458     device[5] = devchar;
3459     char lines_0[] = ",";
3460     char *lines[] = {
3461       lines_0,
3462       NULL
3463     };
3464     int r;
3465     suppress_error = 0;
3466     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3467     if (r == -1)
3468       return -1;
3469   }
3470   {
3471     char fstype[] = "ext2";
3472     char device[] = "/dev/sda1";
3473     device[5] = devchar;
3474     int r;
3475     suppress_error = 0;
3476     r = guestfs_mkfs (g, fstype, device);
3477     if (r == -1)
3478       return -1;
3479   }
3480   {
3481     char device[] = "/dev/sda1";
3482     device[5] = devchar;
3483     char mountpoint[] = "/";
3484     int r;
3485     suppress_error = 0;
3486     r = guestfs_mount (g, device, mountpoint);
3487     if (r == -1)
3488       return -1;
3489   }
3490   /* TestLastFail for checksum (1) */
3491   {
3492     char csumtype[] = "crc";
3493     char path[] = "/new";
3494     char *r;
3495     suppress_error = 1;
3496     r = guestfs_checksum (g, csumtype, path);
3497     if (r != NULL)
3498       return -1;
3499     free (r);
3500   }
3501   return 0;
3502 }
3503
3504 static int test_checksum_2 (void)
3505 {
3506   /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
3507   {
3508     char device[] = "/dev/sda";
3509     device[5] = devchar;
3510     int r;
3511     suppress_error = 0;
3512     r = guestfs_blockdev_setrw (g, device);
3513     if (r == -1)
3514       return -1;
3515   }
3516   {
3517     int r;
3518     suppress_error = 0;
3519     r = guestfs_umount_all (g);
3520     if (r == -1)
3521       return -1;
3522   }
3523   {
3524     int r;
3525     suppress_error = 0;
3526     r = guestfs_lvm_remove_all (g);
3527     if (r == -1)
3528       return -1;
3529   }
3530   {
3531     char device[] = "/dev/sda";
3532     device[5] = devchar;
3533     char lines_0[] = ",";
3534     char *lines[] = {
3535       lines_0,
3536       NULL
3537     };
3538     int r;
3539     suppress_error = 0;
3540     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3541     if (r == -1)
3542       return -1;
3543   }
3544   {
3545     char fstype[] = "ext2";
3546     char device[] = "/dev/sda1";
3547     device[5] = devchar;
3548     int r;
3549     suppress_error = 0;
3550     r = guestfs_mkfs (g, fstype, device);
3551     if (r == -1)
3552       return -1;
3553   }
3554   {
3555     char device[] = "/dev/sda1";
3556     device[5] = devchar;
3557     char mountpoint[] = "/";
3558     int r;
3559     suppress_error = 0;
3560     r = guestfs_mount (g, device, mountpoint);
3561     if (r == -1)
3562       return -1;
3563   }
3564   /* TestOutput for checksum (2) */
3565   char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
3566   {
3567     char path[] = "/new";
3568     char content[] = "test\n";
3569     int r;
3570     suppress_error = 0;
3571     r = guestfs_write_file (g, path, content, 0);
3572     if (r == -1)
3573       return -1;
3574   }
3575   {
3576     char csumtype[] = "md5";
3577     char path[] = "/new";
3578     char *r;
3579     suppress_error = 0;
3580     r = guestfs_checksum (g, csumtype, path);
3581     if (r == NULL)
3582       return -1;
3583     if (strcmp (r, expected) != 0) {
3584       fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
3585       return -1;
3586     }
3587     free (r);
3588   }
3589   return 0;
3590 }
3591
3592 static int test_checksum_3 (void)
3593 {
3594   /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
3595   {
3596     char device[] = "/dev/sda";
3597     device[5] = devchar;
3598     int r;
3599     suppress_error = 0;
3600     r = guestfs_blockdev_setrw (g, device);
3601     if (r == -1)
3602       return -1;
3603   }
3604   {
3605     int r;
3606     suppress_error = 0;
3607     r = guestfs_umount_all (g);
3608     if (r == -1)
3609       return -1;
3610   }
3611   {
3612     int r;
3613     suppress_error = 0;
3614     r = guestfs_lvm_remove_all (g);
3615     if (r == -1)
3616       return -1;
3617   }
3618   {
3619     char device[] = "/dev/sda";
3620     device[5] = devchar;
3621     char lines_0[] = ",";
3622     char *lines[] = {
3623       lines_0,
3624       NULL
3625     };
3626     int r;
3627     suppress_error = 0;
3628     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3629     if (r == -1)
3630       return -1;
3631   }
3632   {
3633     char fstype[] = "ext2";
3634     char device[] = "/dev/sda1";
3635     device[5] = devchar;
3636     int r;
3637     suppress_error = 0;
3638     r = guestfs_mkfs (g, fstype, device);
3639     if (r == -1)
3640       return -1;
3641   }
3642   {
3643     char device[] = "/dev/sda1";
3644     device[5] = devchar;
3645     char mountpoint[] = "/";
3646     int r;
3647     suppress_error = 0;
3648     r = guestfs_mount (g, device, mountpoint);
3649     if (r == -1)
3650       return -1;
3651   }
3652   /* TestOutput for checksum (3) */
3653   char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
3654   {
3655     char path[] = "/new";
3656     char content[] = "test\n";
3657     int r;
3658     suppress_error = 0;
3659     r = guestfs_write_file (g, path, content, 0);
3660     if (r == -1)
3661       return -1;
3662   }
3663   {
3664     char csumtype[] = "sha1";
3665     char path[] = "/new";
3666     char *r;
3667     suppress_error = 0;
3668     r = guestfs_checksum (g, csumtype, path);
3669     if (r == NULL)
3670       return -1;
3671     if (strcmp (r, expected) != 0) {
3672       fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
3673       return -1;
3674     }
3675     free (r);
3676   }
3677   return 0;
3678 }
3679
3680 static int test_checksum_4 (void)
3681 {
3682   /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
3683   {
3684     char device[] = "/dev/sda";
3685     device[5] = devchar;
3686     int r;
3687     suppress_error = 0;
3688     r = guestfs_blockdev_setrw (g, device);
3689     if (r == -1)
3690       return -1;
3691   }
3692   {
3693     int r;
3694     suppress_error = 0;
3695     r = guestfs_umount_all (g);
3696     if (r == -1)
3697       return -1;
3698   }
3699   {
3700     int r;
3701     suppress_error = 0;
3702     r = guestfs_lvm_remove_all (g);
3703     if (r == -1)
3704       return -1;
3705   }
3706   {
3707     char device[] = "/dev/sda";
3708     device[5] = devchar;
3709     char lines_0[] = ",";
3710     char *lines[] = {
3711       lines_0,
3712       NULL
3713     };
3714     int r;
3715     suppress_error = 0;
3716     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3717     if (r == -1)
3718       return -1;
3719   }
3720   {
3721     char fstype[] = "ext2";
3722     char device[] = "/dev/sda1";
3723     device[5] = devchar;
3724     int r;
3725     suppress_error = 0;
3726     r = guestfs_mkfs (g, fstype, device);
3727     if (r == -1)
3728       return -1;
3729   }
3730   {
3731     char device[] = "/dev/sda1";
3732     device[5] = devchar;
3733     char mountpoint[] = "/";
3734     int r;
3735     suppress_error = 0;
3736     r = guestfs_mount (g, device, mountpoint);
3737     if (r == -1)
3738       return -1;
3739   }
3740   /* TestOutput for checksum (4) */
3741   char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
3742   {
3743     char path[] = "/new";
3744     char content[] = "test\n";
3745     int r;
3746     suppress_error = 0;
3747     r = guestfs_write_file (g, path, content, 0);
3748     if (r == -1)
3749       return -1;
3750   }
3751   {
3752     char csumtype[] = "sha224";
3753     char path[] = "/new";
3754     char *r;
3755     suppress_error = 0;
3756     r = guestfs_checksum (g, csumtype, path);
3757     if (r == NULL)
3758       return -1;
3759     if (strcmp (r, expected) != 0) {
3760       fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
3761       return -1;
3762     }
3763     free (r);
3764   }
3765   return 0;
3766 }
3767
3768 static int test_checksum_5 (void)
3769 {
3770   /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
3771   {
3772     char device[] = "/dev/sda";
3773     device[5] = devchar;
3774     int r;
3775     suppress_error = 0;
3776     r = guestfs_blockdev_setrw (g, device);
3777     if (r == -1)
3778       return -1;
3779   }
3780   {
3781     int r;
3782     suppress_error = 0;
3783     r = guestfs_umount_all (g);
3784     if (r == -1)
3785       return -1;
3786   }
3787   {
3788     int r;
3789     suppress_error = 0;
3790     r = guestfs_lvm_remove_all (g);
3791     if (r == -1)
3792       return -1;
3793   }
3794   {
3795     char device[] = "/dev/sda";
3796     device[5] = devchar;
3797     char lines_0[] = ",";
3798     char *lines[] = {
3799       lines_0,
3800       NULL
3801     };
3802     int r;
3803     suppress_error = 0;
3804     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3805     if (r == -1)
3806       return -1;
3807   }
3808   {
3809     char fstype[] = "ext2";
3810     char device[] = "/dev/sda1";
3811     device[5] = devchar;
3812     int r;
3813     suppress_error = 0;
3814     r = guestfs_mkfs (g, fstype, device);
3815     if (r == -1)
3816       return -1;
3817   }
3818   {
3819     char device[] = "/dev/sda1";
3820     device[5] = devchar;
3821     char mountpoint[] = "/";
3822     int r;
3823     suppress_error = 0;
3824     r = guestfs_mount (g, device, mountpoint);
3825     if (r == -1)
3826       return -1;
3827   }
3828   /* TestOutput for checksum (5) */
3829   char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
3830   {
3831     char path[] = "/new";
3832     char content[] = "test\n";
3833     int r;
3834     suppress_error = 0;
3835     r = guestfs_write_file (g, path, content, 0);
3836     if (r == -1)
3837       return -1;
3838   }
3839   {
3840     char csumtype[] = "sha256";
3841     char path[] = "/new";
3842     char *r;
3843     suppress_error = 0;
3844     r = guestfs_checksum (g, csumtype, path);
3845     if (r == NULL)
3846       return -1;
3847     if (strcmp (r, expected) != 0) {
3848       fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
3849       return -1;
3850     }
3851     free (r);
3852   }
3853   return 0;
3854 }
3855
3856 static int test_checksum_6 (void)
3857 {
3858   /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
3859   {
3860     char device[] = "/dev/sda";
3861     device[5] = devchar;
3862     int r;
3863     suppress_error = 0;
3864     r = guestfs_blockdev_setrw (g, device);
3865     if (r == -1)
3866       return -1;
3867   }
3868   {
3869     int r;
3870     suppress_error = 0;
3871     r = guestfs_umount_all (g);
3872     if (r == -1)
3873       return -1;
3874   }
3875   {
3876     int r;
3877     suppress_error = 0;
3878     r = guestfs_lvm_remove_all (g);
3879     if (r == -1)
3880       return -1;
3881   }
3882   {
3883     char device[] = "/dev/sda";
3884     device[5] = devchar;
3885     char lines_0[] = ",";
3886     char *lines[] = {
3887       lines_0,
3888       NULL
3889     };
3890     int r;
3891     suppress_error = 0;
3892     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3893     if (r == -1)
3894       return -1;
3895   }
3896   {
3897     char fstype[] = "ext2";
3898     char device[] = "/dev/sda1";
3899     device[5] = devchar;
3900     int r;
3901     suppress_error = 0;
3902     r = guestfs_mkfs (g, fstype, device);
3903     if (r == -1)
3904       return -1;
3905   }
3906   {
3907     char device[] = "/dev/sda1";
3908     device[5] = devchar;
3909     char mountpoint[] = "/";
3910     int r;
3911     suppress_error = 0;
3912     r = guestfs_mount (g, device, mountpoint);
3913     if (r == -1)
3914       return -1;
3915   }
3916   /* TestOutput for checksum (6) */
3917   char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
3918   {
3919     char path[] = "/new";
3920     char content[] = "test\n";
3921     int r;
3922     suppress_error = 0;
3923     r = guestfs_write_file (g, path, content, 0);
3924     if (r == -1)
3925       return -1;
3926   }
3927   {
3928     char csumtype[] = "sha384";
3929     char path[] = "/new";
3930     char *r;
3931     suppress_error = 0;
3932     r = guestfs_checksum (g, csumtype, path);
3933     if (r == NULL)
3934       return -1;
3935     if (strcmp (r, expected) != 0) {
3936       fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
3937       return -1;
3938     }
3939     free (r);
3940   }
3941   return 0;
3942 }
3943
3944 static int test_checksum_7 (void)
3945 {
3946   /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
3947   {
3948     char device[] = "/dev/sda";
3949     device[5] = devchar;
3950     int r;
3951     suppress_error = 0;
3952     r = guestfs_blockdev_setrw (g, device);
3953     if (r == -1)
3954       return -1;
3955   }
3956   {
3957     int r;
3958     suppress_error = 0;
3959     r = guestfs_umount_all (g);
3960     if (r == -1)
3961       return -1;
3962   }
3963   {
3964     int r;
3965     suppress_error = 0;
3966     r = guestfs_lvm_remove_all (g);
3967     if (r == -1)
3968       return -1;
3969   }
3970   {
3971     char device[] = "/dev/sda";
3972     device[5] = devchar;
3973     char lines_0[] = ",";
3974     char *lines[] = {
3975       lines_0,
3976       NULL
3977     };
3978     int r;
3979     suppress_error = 0;
3980     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3981     if (r == -1)
3982       return -1;
3983   }
3984   {
3985     char fstype[] = "ext2";
3986     char device[] = "/dev/sda1";
3987     device[5] = devchar;
3988     int r;
3989     suppress_error = 0;
3990     r = guestfs_mkfs (g, fstype, device);
3991     if (r == -1)
3992       return -1;
3993   }
3994   {
3995     char device[] = "/dev/sda1";
3996     device[5] = devchar;
3997     char mountpoint[] = "/";
3998     int r;
3999     suppress_error = 0;
4000     r = guestfs_mount (g, device, mountpoint);
4001     if (r == -1)
4002       return -1;
4003   }
4004   /* TestOutput for checksum (7) */
4005   char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
4006   {
4007     char path[] = "/new";
4008     char content[] = "test\n";
4009     int r;
4010     suppress_error = 0;
4011     r = guestfs_write_file (g, path, content, 0);
4012     if (r == -1)
4013       return -1;
4014   }
4015   {
4016     char csumtype[] = "sha512";
4017     char path[] = "/new";
4018     char *r;
4019     suppress_error = 0;
4020     r = guestfs_checksum (g, csumtype, path);
4021     if (r == NULL)
4022       return -1;
4023     if (strcmp (r, expected) != 0) {
4024       fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
4025       return -1;
4026     }
4027     free (r);
4028   }
4029   return 0;
4030 }
4031
4032 static int test_download_0 (void)
4033 {
4034   /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
4035   {
4036     char device[] = "/dev/sda";
4037     device[5] = devchar;
4038     int r;
4039     suppress_error = 0;
4040     r = guestfs_blockdev_setrw (g, device);
4041     if (r == -1)
4042       return -1;
4043   }
4044   {
4045     int r;
4046     suppress_error = 0;
4047     r = guestfs_umount_all (g);
4048     if (r == -1)
4049       return -1;
4050   }
4051   {
4052     int r;
4053     suppress_error = 0;
4054     r = guestfs_lvm_remove_all (g);
4055     if (r == -1)
4056       return -1;
4057   }
4058   {
4059     char device[] = "/dev/sda";
4060     device[5] = devchar;
4061     char lines_0[] = ",";
4062     char *lines[] = {
4063       lines_0,
4064       NULL
4065     };
4066     int r;
4067     suppress_error = 0;
4068     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4069     if (r == -1)
4070       return -1;
4071   }
4072   {
4073     char fstype[] = "ext2";
4074     char device[] = "/dev/sda1";
4075     device[5] = devchar;
4076     int r;
4077     suppress_error = 0;
4078     r = guestfs_mkfs (g, fstype, device);
4079     if (r == -1)
4080       return -1;
4081   }
4082   {
4083     char device[] = "/dev/sda1";
4084     device[5] = devchar;
4085     char mountpoint[] = "/";
4086     int r;
4087     suppress_error = 0;
4088     r = guestfs_mount (g, device, mountpoint);
4089     if (r == -1)
4090       return -1;
4091   }
4092   /* TestOutput for download (0) */
4093   char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4094   {
4095     char remotefilename[] = "/COPYING.LIB";
4096     int r;
4097     suppress_error = 0;
4098     r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4099     if (r == -1)
4100       return -1;
4101   }
4102   {
4103     char remotefilename[] = "/COPYING.LIB";
4104     int r;
4105     suppress_error = 0;
4106     r = guestfs_download (g, remotefilename, "testdownload.tmp");
4107     if (r == -1)
4108       return -1;
4109   }
4110   {
4111     char remotefilename[] = "/upload";
4112     int r;
4113     suppress_error = 0;
4114     r = guestfs_upload (g, "testdownload.tmp", remotefilename);
4115     if (r == -1)
4116       return -1;
4117   }
4118   {
4119     char csumtype[] = "md5";
4120     char path[] = "/upload";
4121     char *r;
4122     suppress_error = 0;
4123     r = guestfs_checksum (g, csumtype, path);
4124     if (r == NULL)
4125       return -1;
4126     if (strcmp (r, expected) != 0) {
4127       fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
4128       return -1;
4129     }
4130     free (r);
4131   }
4132   return 0;
4133 }
4134
4135 static int test_upload_0 (void)
4136 {
4137   /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
4138   {
4139     char device[] = "/dev/sda";
4140     device[5] = devchar;
4141     int r;
4142     suppress_error = 0;
4143     r = guestfs_blockdev_setrw (g, device);
4144     if (r == -1)
4145       return -1;
4146   }
4147   {
4148     int r;
4149     suppress_error = 0;
4150     r = guestfs_umount_all (g);
4151     if (r == -1)
4152       return -1;
4153   }
4154   {
4155     int r;
4156     suppress_error = 0;
4157     r = guestfs_lvm_remove_all (g);
4158     if (r == -1)
4159       return -1;
4160   }
4161   {
4162     char device[] = "/dev/sda";
4163     device[5] = devchar;
4164     char lines_0[] = ",";
4165     char *lines[] = {
4166       lines_0,
4167       NULL
4168     };
4169     int r;
4170     suppress_error = 0;
4171     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4172     if (r == -1)
4173       return -1;
4174   }
4175   {
4176     char fstype[] = "ext2";
4177     char device[] = "/dev/sda1";
4178     device[5] = devchar;
4179     int r;
4180     suppress_error = 0;
4181     r = guestfs_mkfs (g, fstype, device);
4182     if (r == -1)
4183       return -1;
4184   }
4185   {
4186     char device[] = "/dev/sda1";
4187     device[5] = devchar;
4188     char mountpoint[] = "/";
4189     int r;
4190     suppress_error = 0;
4191     r = guestfs_mount (g, device, mountpoint);
4192     if (r == -1)
4193       return -1;
4194   }
4195   /* TestOutput for upload (0) */
4196   char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4197   {
4198     char remotefilename[] = "/COPYING.LIB";
4199     int r;
4200     suppress_error = 0;
4201     r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4202     if (r == -1)
4203       return -1;
4204   }
4205   {
4206     char csumtype[] = "md5";
4207     char path[] = "/COPYING.LIB";
4208     char *r;
4209     suppress_error = 0;
4210     r = guestfs_checksum (g, csumtype, path);
4211     if (r == NULL)
4212       return -1;
4213     if (strcmp (r, expected) != 0) {
4214       fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
4215       return -1;
4216     }
4217     free (r);
4218   }
4219   return 0;
4220 }
4221
4222 static int test_blockdev_rereadpt_0 (void)
4223 {
4224   /* InitEmpty for blockdev_rereadpt (0) */
4225   {
4226     char device[] = "/dev/sda";
4227     device[5] = devchar;
4228     int r;
4229     suppress_error = 0;
4230     r = guestfs_blockdev_setrw (g, device);
4231     if (r == -1)
4232       return -1;
4233   }
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   /* TestRun for blockdev_rereadpt (0) */
4249   {
4250     char device[] = "/dev/sda";
4251     device[5] = devchar;
4252     int r;
4253     suppress_error = 0;
4254     r = guestfs_blockdev_rereadpt (g, device);
4255     if (r == -1)
4256       return -1;
4257   }
4258   return 0;
4259 }
4260
4261 static int test_blockdev_flushbufs_0 (void)
4262 {
4263   /* InitEmpty for blockdev_flushbufs (0) */
4264   {
4265     char device[] = "/dev/sda";
4266     device[5] = devchar;
4267     int r;
4268     suppress_error = 0;
4269     r = guestfs_blockdev_setrw (g, device);
4270     if (r == -1)
4271       return -1;
4272   }
4273   {
4274     int r;
4275     suppress_error = 0;
4276     r = guestfs_umount_all (g);
4277     if (r == -1)
4278       return -1;
4279   }
4280   {
4281     int r;
4282     suppress_error = 0;
4283     r = guestfs_lvm_remove_all (g);
4284     if (r == -1)
4285       return -1;
4286   }
4287   /* TestRun for blockdev_flushbufs (0) */
4288   {
4289     char device[] = "/dev/sda";
4290     device[5] = devchar;
4291     int r;
4292     suppress_error = 0;
4293     r = guestfs_blockdev_flushbufs (g, device);
4294     if (r == -1)
4295       return -1;
4296   }
4297   return 0;
4298 }
4299
4300 static int test_blockdev_getsize64_0 (void)
4301 {
4302   /* InitEmpty for blockdev_getsize64 (0) */
4303   {
4304     char device[] = "/dev/sda";
4305     device[5] = devchar;
4306     int r;
4307     suppress_error = 0;
4308     r = guestfs_blockdev_setrw (g, device);
4309     if (r == -1)
4310       return -1;
4311   }
4312   {
4313     int r;
4314     suppress_error = 0;
4315     r = guestfs_umount_all (g);
4316     if (r == -1)
4317       return -1;
4318   }
4319   {
4320     int r;
4321     suppress_error = 0;
4322     r = guestfs_lvm_remove_all (g);
4323     if (r == -1)
4324       return -1;
4325   }
4326   /* TestOutputInt for blockdev_getsize64 (0) */
4327   {
4328     char device[] = "/dev/sda";
4329     device[5] = devchar;
4330     int64_t r;
4331     suppress_error = 0;
4332     r = guestfs_blockdev_getsize64 (g, device);
4333     if (r == -1)
4334       return -1;
4335     if (r != 524288000) {
4336       fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n",               (int) r);
4337       return -1;
4338     }
4339   }
4340   return 0;
4341 }
4342
4343 static int test_blockdev_getsz_0 (void)
4344 {
4345   /* InitEmpty for blockdev_getsz (0) */
4346   {
4347     char device[] = "/dev/sda";
4348     device[5] = devchar;
4349     int r;
4350     suppress_error = 0;
4351     r = guestfs_blockdev_setrw (g, device);
4352     if (r == -1)
4353       return -1;
4354   }
4355   {
4356     int r;
4357     suppress_error = 0;
4358     r = guestfs_umount_all (g);
4359     if (r == -1)
4360       return -1;
4361   }
4362   {
4363     int r;
4364     suppress_error = 0;
4365     r = guestfs_lvm_remove_all (g);
4366     if (r == -1)
4367       return -1;
4368   }
4369   /* TestOutputInt for blockdev_getsz (0) */
4370   {
4371     char device[] = "/dev/sda";
4372     device[5] = devchar;
4373     int64_t r;
4374     suppress_error = 0;
4375     r = guestfs_blockdev_getsz (g, device);
4376     if (r == -1)
4377       return -1;
4378     if (r != 1024000) {
4379       fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n",               (int) r);
4380       return -1;
4381     }
4382   }
4383   return 0;
4384 }
4385
4386 static int test_blockdev_getbsz_0 (void)
4387 {
4388   /* InitEmpty for blockdev_getbsz (0) */
4389   {
4390     char device[] = "/dev/sda";
4391     device[5] = devchar;
4392     int r;
4393     suppress_error = 0;
4394     r = guestfs_blockdev_setrw (g, device);
4395     if (r == -1)
4396       return -1;
4397   }
4398   {
4399     int r;
4400     suppress_error = 0;
4401     r = guestfs_umount_all (g);
4402     if (r == -1)
4403       return -1;
4404   }
4405   {
4406     int r;
4407     suppress_error = 0;
4408     r = guestfs_lvm_remove_all (g);
4409     if (r == -1)
4410       return -1;
4411   }
4412   /* TestOutputInt for blockdev_getbsz (0) */
4413   {
4414     char device[] = "/dev/sda";
4415     device[5] = devchar;
4416     int r;
4417     suppress_error = 0;
4418     r = guestfs_blockdev_getbsz (g, device);
4419     if (r == -1)
4420       return -1;
4421     if (r != 4096) {
4422       fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n",               (int) r);
4423       return -1;
4424     }
4425   }
4426   return 0;
4427 }
4428
4429 static int test_blockdev_getss_0 (void)
4430 {
4431   /* InitEmpty for blockdev_getss (0) */
4432   {
4433     char device[] = "/dev/sda";
4434     device[5] = devchar;
4435     int r;
4436     suppress_error = 0;
4437     r = guestfs_blockdev_setrw (g, device);
4438     if (r == -1)
4439       return -1;
4440   }
4441   {
4442     int r;
4443     suppress_error = 0;
4444     r = guestfs_umount_all (g);
4445     if (r == -1)
4446       return -1;
4447   }
4448   {
4449     int r;
4450     suppress_error = 0;
4451     r = guestfs_lvm_remove_all (g);
4452     if (r == -1)
4453       return -1;
4454   }
4455   /* TestOutputInt for blockdev_getss (0) */
4456   {
4457     char device[] = "/dev/sda";
4458     device[5] = devchar;
4459     int r;
4460     suppress_error = 0;
4461     r = guestfs_blockdev_getss (g, device);
4462     if (r == -1)
4463       return -1;
4464     if (r != 512) {
4465       fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n",               (int) r);
4466       return -1;
4467     }
4468   }
4469   return 0;
4470 }
4471
4472 static int test_blockdev_getro_0 (void)
4473 {
4474   /* InitEmpty for blockdev_getro (0) */
4475   {
4476     char device[] = "/dev/sda";
4477     device[5] = devchar;
4478     int r;
4479     suppress_error = 0;
4480     r = guestfs_blockdev_setrw (g, device);
4481     if (r == -1)
4482       return -1;
4483   }
4484   {
4485     int r;
4486     suppress_error = 0;
4487     r = guestfs_umount_all (g);
4488     if (r == -1)
4489       return -1;
4490   }
4491   {
4492     int r;
4493     suppress_error = 0;
4494     r = guestfs_lvm_remove_all (g);
4495     if (r == -1)
4496       return -1;
4497   }
4498   /* TestOutputTrue for blockdev_getro (0) */
4499   {
4500     char device[] = "/dev/sda";
4501     device[5] = devchar;
4502     int r;
4503     suppress_error = 0;
4504     r = guestfs_blockdev_setro (g, device);
4505     if (r == -1)
4506       return -1;
4507   }
4508   {
4509     char device[] = "/dev/sda";
4510     device[5] = devchar;
4511     int r;
4512     suppress_error = 0;
4513     r = guestfs_blockdev_getro (g, device);
4514     if (r == -1)
4515       return -1;
4516     if (!r) {
4517       fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
4518       return -1;
4519     }
4520   }
4521   return 0;
4522 }
4523
4524 static int test_blockdev_setrw_0 (void)
4525 {
4526   /* InitEmpty for blockdev_setrw (0) */
4527   {
4528     char device[] = "/dev/sda";
4529     device[5] = devchar;
4530     int r;
4531     suppress_error = 0;
4532     r = guestfs_blockdev_setrw (g, device);
4533     if (r == -1)
4534       return -1;
4535   }
4536   {
4537     int r;
4538     suppress_error = 0;
4539     r = guestfs_umount_all (g);
4540     if (r == -1)
4541       return -1;
4542   }
4543   {
4544     int r;
4545     suppress_error = 0;
4546     r = guestfs_lvm_remove_all (g);
4547     if (r == -1)
4548       return -1;
4549   }
4550   /* TestOutputFalse for blockdev_setrw (0) */
4551   {
4552     char device[] = "/dev/sda";
4553     device[5] = devchar;
4554     int r;
4555     suppress_error = 0;
4556     r = guestfs_blockdev_setrw (g, device);
4557     if (r == -1)
4558       return -1;
4559   }
4560   {
4561     char device[] = "/dev/sda";
4562     device[5] = devchar;
4563     int r;
4564     suppress_error = 0;
4565     r = guestfs_blockdev_getro (g, device);
4566     if (r == -1)
4567       return -1;
4568     if (r) {
4569       fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
4570       return -1;
4571     }
4572   }
4573   return 0;
4574 }
4575
4576 static int test_blockdev_setro_0 (void)
4577 {
4578   /* InitEmpty for blockdev_setro (0) */
4579   {
4580     char device[] = "/dev/sda";
4581     device[5] = devchar;
4582     int r;
4583     suppress_error = 0;
4584     r = guestfs_blockdev_setrw (g, device);
4585     if (r == -1)
4586       return -1;
4587   }
4588   {
4589     int r;
4590     suppress_error = 0;
4591     r = guestfs_umount_all (g);
4592     if (r == -1)
4593       return -1;
4594   }
4595   {
4596     int r;
4597     suppress_error = 0;
4598     r = guestfs_lvm_remove_all (g);
4599     if (r == -1)
4600       return -1;
4601   }
4602   /* TestOutputTrue for blockdev_setro (0) */
4603   {
4604     char device[] = "/dev/sda";
4605     device[5] = devchar;
4606     int r;
4607     suppress_error = 0;
4608     r = guestfs_blockdev_setro (g, device);
4609     if (r == -1)
4610       return -1;
4611   }
4612   {
4613     char device[] = "/dev/sda";
4614     device[5] = devchar;
4615     int r;
4616     suppress_error = 0;
4617     r = guestfs_blockdev_getro (g, device);
4618     if (r == -1)
4619       return -1;
4620     if (!r) {
4621       fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
4622       return -1;
4623     }
4624   }
4625   return 0;
4626 }
4627
4628 static int test_statvfs_0 (void)
4629 {
4630   /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
4631   {
4632     char device[] = "/dev/sda";
4633     device[5] = devchar;
4634     int r;
4635     suppress_error = 0;
4636     r = guestfs_blockdev_setrw (g, device);
4637     if (r == -1)
4638       return -1;
4639   }
4640   {
4641     int r;
4642     suppress_error = 0;
4643     r = guestfs_umount_all (g);
4644     if (r == -1)
4645       return -1;
4646   }
4647   {
4648     int r;
4649     suppress_error = 0;
4650     r = guestfs_lvm_remove_all (g);
4651     if (r == -1)
4652       return -1;
4653   }
4654   {
4655     char device[] = "/dev/sda";
4656     device[5] = devchar;
4657     char lines_0[] = ",";
4658     char *lines[] = {
4659       lines_0,
4660       NULL
4661     };
4662     int r;
4663     suppress_error = 0;
4664     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4665     if (r == -1)
4666       return -1;
4667   }
4668   {
4669     char fstype[] = "ext2";
4670     char device[] = "/dev/sda1";
4671     device[5] = devchar;
4672     int r;
4673     suppress_error = 0;
4674     r = guestfs_mkfs (g, fstype, device);
4675     if (r == -1)
4676       return -1;
4677   }
4678   {
4679     char device[] = "/dev/sda1";
4680     device[5] = devchar;
4681     char mountpoint[] = "/";
4682     int r;
4683     suppress_error = 0;
4684     r = guestfs_mount (g, device, mountpoint);
4685     if (r == -1)
4686       return -1;
4687   }
4688   /* TestOutputStruct for statvfs (0) */
4689   {
4690     char path[] = "/";
4691     struct guestfs_statvfs *r;
4692     suppress_error = 0;
4693     r = guestfs_statvfs (g, path);
4694     if (r == NULL)
4695       return -1;
4696     if (r->bfree != 487702) {
4697       fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
4698                (int) r->bfree);
4699       return -1;
4700     }
4701     if (r->blocks != 490020) {
4702       fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
4703                (int) r->blocks);
4704       return -1;
4705     }
4706     if (r->bsize != 1024) {
4707       fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
4708                (int) r->bsize);
4709       return -1;
4710     }
4711     free (r);
4712   }
4713   return 0;
4714 }
4715
4716 static int test_lstat_0 (void)
4717 {
4718   /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
4719   {
4720     char device[] = "/dev/sda";
4721     device[5] = devchar;
4722     int r;
4723     suppress_error = 0;
4724     r = guestfs_blockdev_setrw (g, device);
4725     if (r == -1)
4726       return -1;
4727   }
4728   {
4729     int r;
4730     suppress_error = 0;
4731     r = guestfs_umount_all (g);
4732     if (r == -1)
4733       return -1;
4734   }
4735   {
4736     int r;
4737     suppress_error = 0;
4738     r = guestfs_lvm_remove_all (g);
4739     if (r == -1)
4740       return -1;
4741   }
4742   {
4743     char device[] = "/dev/sda";
4744     device[5] = devchar;
4745     char lines_0[] = ",";
4746     char *lines[] = {
4747       lines_0,
4748       NULL
4749     };
4750     int r;
4751     suppress_error = 0;
4752     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4753     if (r == -1)
4754       return -1;
4755   }
4756   {
4757     char fstype[] = "ext2";
4758     char device[] = "/dev/sda1";
4759     device[5] = devchar;
4760     int r;
4761     suppress_error = 0;
4762     r = guestfs_mkfs (g, fstype, device);
4763     if (r == -1)
4764       return -1;
4765   }
4766   {
4767     char device[] = "/dev/sda1";
4768     device[5] = devchar;
4769     char mountpoint[] = "/";
4770     int r;
4771     suppress_error = 0;
4772     r = guestfs_mount (g, device, mountpoint);
4773     if (r == -1)
4774       return -1;
4775   }
4776   /* TestOutputStruct for lstat (0) */
4777   {
4778     char path[] = "/new";
4779     int r;
4780     suppress_error = 0;
4781     r = guestfs_touch (g, path);
4782     if (r == -1)
4783       return -1;
4784   }
4785   {
4786     char path[] = "/new";
4787     struct guestfs_stat *r;
4788     suppress_error = 0;
4789     r = guestfs_lstat (g, path);
4790     if (r == NULL)
4791       return -1;
4792     if (r->size != 0) {
4793       fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
4794                (int) r->size);
4795       return -1;
4796     }
4797     free (r);
4798   }
4799   return 0;
4800 }
4801
4802 static int test_stat_0 (void)
4803 {
4804   /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
4805   {
4806     char device[] = "/dev/sda";
4807     device[5] = devchar;
4808     int r;
4809     suppress_error = 0;
4810     r = guestfs_blockdev_setrw (g, device);
4811     if (r == -1)
4812       return -1;
4813   }
4814   {
4815     int r;
4816     suppress_error = 0;
4817     r = guestfs_umount_all (g);
4818     if (r == -1)
4819       return -1;
4820   }
4821   {
4822     int r;
4823     suppress_error = 0;
4824     r = guestfs_lvm_remove_all (g);
4825     if (r == -1)
4826       return -1;
4827   }
4828   {
4829     char device[] = "/dev/sda";
4830     device[5] = devchar;
4831     char lines_0[] = ",";
4832     char *lines[] = {
4833       lines_0,
4834       NULL
4835     };
4836     int r;
4837     suppress_error = 0;
4838     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4839     if (r == -1)
4840       return -1;
4841   }
4842   {
4843     char fstype[] = "ext2";
4844     char device[] = "/dev/sda1";
4845     device[5] = devchar;
4846     int r;
4847     suppress_error = 0;
4848     r = guestfs_mkfs (g, fstype, device);
4849     if (r == -1)
4850       return -1;
4851   }
4852   {
4853     char device[] = "/dev/sda1";
4854     device[5] = devchar;
4855     char mountpoint[] = "/";
4856     int r;
4857     suppress_error = 0;
4858     r = guestfs_mount (g, device, mountpoint);
4859     if (r == -1)
4860       return -1;
4861   }
4862   /* TestOutputStruct for stat (0) */
4863   {
4864     char path[] = "/new";
4865     int r;
4866     suppress_error = 0;
4867     r = guestfs_touch (g, path);
4868     if (r == -1)
4869       return -1;
4870   }
4871   {
4872     char path[] = "/new";
4873     struct guestfs_stat *r;
4874     suppress_error = 0;
4875     r = guestfs_stat (g, path);
4876     if (r == NULL)
4877       return -1;
4878     if (r->size != 0) {
4879       fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
4880                (int) r->size);
4881       return -1;
4882     }
4883     free (r);
4884   }
4885   return 0;
4886 }
4887
4888 static int test_file_0 (void)
4889 {
4890   /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
4891   {
4892     char device[] = "/dev/sda";
4893     device[5] = devchar;
4894     int r;
4895     suppress_error = 0;
4896     r = guestfs_blockdev_setrw (g, device);
4897     if (r == -1)
4898       return -1;
4899   }
4900   {
4901     int r;
4902     suppress_error = 0;
4903     r = guestfs_umount_all (g);
4904     if (r == -1)
4905       return -1;
4906   }
4907   {
4908     int r;
4909     suppress_error = 0;
4910     r = guestfs_lvm_remove_all (g);
4911     if (r == -1)
4912       return -1;
4913   }
4914   {
4915     char device[] = "/dev/sda";
4916     device[5] = devchar;
4917     char lines_0[] = ",";
4918     char *lines[] = {
4919       lines_0,
4920       NULL
4921     };
4922     int r;
4923     suppress_error = 0;
4924     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4925     if (r == -1)
4926       return -1;
4927   }
4928   {
4929     char fstype[] = "ext2";
4930     char device[] = "/dev/sda1";
4931     device[5] = devchar;
4932     int r;
4933     suppress_error = 0;
4934     r = guestfs_mkfs (g, fstype, device);
4935     if (r == -1)
4936       return -1;
4937   }
4938   {
4939     char device[] = "/dev/sda1";
4940     device[5] = devchar;
4941     char mountpoint[] = "/";
4942     int r;
4943     suppress_error = 0;
4944     r = guestfs_mount (g, device, mountpoint);
4945     if (r == -1)
4946       return -1;
4947   }
4948   /* TestOutput for file (0) */
4949   char expected[] = "empty";
4950   {
4951     char path[] = "/new";
4952     int r;
4953     suppress_error = 0;
4954     r = guestfs_touch (g, path);
4955     if (r == -1)
4956       return -1;
4957   }
4958   {
4959     char path[] = "/new";
4960     char *r;
4961     suppress_error = 0;
4962     r = guestfs_file (g, path);
4963     if (r == NULL)
4964       return -1;
4965     if (strcmp (r, expected) != 0) {
4966       fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
4967       return -1;
4968     }
4969     free (r);
4970   }
4971   return 0;
4972 }
4973
4974 static int test_file_1 (void)
4975 {
4976   /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
4977   {
4978     char device[] = "/dev/sda";
4979     device[5] = devchar;
4980     int r;
4981     suppress_error = 0;
4982     r = guestfs_blockdev_setrw (g, device);
4983     if (r == -1)
4984       return -1;
4985   }
4986   {
4987     int r;
4988     suppress_error = 0;
4989     r = guestfs_umount_all (g);
4990     if (r == -1)
4991       return -1;
4992   }
4993   {
4994     int r;
4995     suppress_error = 0;
4996     r = guestfs_lvm_remove_all (g);
4997     if (r == -1)
4998       return -1;
4999   }
5000   {
5001     char device[] = "/dev/sda";
5002     device[5] = devchar;
5003     char lines_0[] = ",";
5004     char *lines[] = {
5005       lines_0,
5006       NULL
5007     };
5008     int r;
5009     suppress_error = 0;
5010     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5011     if (r == -1)
5012       return -1;
5013   }
5014   {
5015     char fstype[] = "ext2";
5016     char device[] = "/dev/sda1";
5017     device[5] = devchar;
5018     int r;
5019     suppress_error = 0;
5020     r = guestfs_mkfs (g, fstype, device);
5021     if (r == -1)
5022       return -1;
5023   }
5024   {
5025     char device[] = "/dev/sda1";
5026     device[5] = devchar;
5027     char mountpoint[] = "/";
5028     int r;
5029     suppress_error = 0;
5030     r = guestfs_mount (g, device, mountpoint);
5031     if (r == -1)
5032       return -1;
5033   }
5034   /* TestOutput for file (1) */
5035   char expected[] = "ASCII text";
5036   {
5037     char path[] = "/new";
5038     char content[] = "some content\n";
5039     int r;
5040     suppress_error = 0;
5041     r = guestfs_write_file (g, path, content, 0);
5042     if (r == -1)
5043       return -1;
5044   }
5045   {
5046     char path[] = "/new";
5047     char *r;
5048     suppress_error = 0;
5049     r = guestfs_file (g, path);
5050     if (r == NULL)
5051       return -1;
5052     if (strcmp (r, expected) != 0) {
5053       fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5054       return -1;
5055     }
5056     free (r);
5057   }
5058   return 0;
5059 }
5060
5061 static int test_file_2 (void)
5062 {
5063   /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
5064   {
5065     char device[] = "/dev/sda";
5066     device[5] = devchar;
5067     int r;
5068     suppress_error = 0;
5069     r = guestfs_blockdev_setrw (g, device);
5070     if (r == -1)
5071       return -1;
5072   }
5073   {
5074     int r;
5075     suppress_error = 0;
5076     r = guestfs_umount_all (g);
5077     if (r == -1)
5078       return -1;
5079   }
5080   {
5081     int r;
5082     suppress_error = 0;
5083     r = guestfs_lvm_remove_all (g);
5084     if (r == -1)
5085       return -1;
5086   }
5087   {
5088     char device[] = "/dev/sda";
5089     device[5] = devchar;
5090     char lines_0[] = ",";
5091     char *lines[] = {
5092       lines_0,
5093       NULL
5094     };
5095     int r;
5096     suppress_error = 0;
5097     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5098     if (r == -1)
5099       return -1;
5100   }
5101   {
5102     char fstype[] = "ext2";
5103     char device[] = "/dev/sda1";
5104     device[5] = devchar;
5105     int r;
5106     suppress_error = 0;
5107     r = guestfs_mkfs (g, fstype, device);
5108     if (r == -1)
5109       return -1;
5110   }
5111   {
5112     char device[] = "/dev/sda1";
5113     device[5] = devchar;
5114     char mountpoint[] = "/";
5115     int r;
5116     suppress_error = 0;
5117     r = guestfs_mount (g, device, mountpoint);
5118     if (r == -1)
5119       return -1;
5120   }
5121   /* TestLastFail for file (2) */
5122   {
5123     char path[] = "/nofile";
5124     char *r;
5125     suppress_error = 1;
5126     r = guestfs_file (g, path);
5127     if (r != NULL)
5128       return -1;
5129     free (r);
5130   }
5131   return 0;
5132 }
5133
5134 static int test_umount_all_0 (void)
5135 {
5136   /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
5137   {
5138     char device[] = "/dev/sda";
5139     device[5] = devchar;
5140     int r;
5141     suppress_error = 0;
5142     r = guestfs_blockdev_setrw (g, device);
5143     if (r == -1)
5144       return -1;
5145   }
5146   {
5147     int r;
5148     suppress_error = 0;
5149     r = guestfs_umount_all (g);
5150     if (r == -1)
5151       return -1;
5152   }
5153   {
5154     int r;
5155     suppress_error = 0;
5156     r = guestfs_lvm_remove_all (g);
5157     if (r == -1)
5158       return -1;
5159   }
5160   {
5161     char device[] = "/dev/sda";
5162     device[5] = devchar;
5163     char lines_0[] = ",";
5164     char *lines[] = {
5165       lines_0,
5166       NULL
5167     };
5168     int r;
5169     suppress_error = 0;
5170     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5171     if (r == -1)
5172       return -1;
5173   }
5174   {
5175     char fstype[] = "ext2";
5176     char device[] = "/dev/sda1";
5177     device[5] = devchar;
5178     int r;
5179     suppress_error = 0;
5180     r = guestfs_mkfs (g, fstype, device);
5181     if (r == -1)
5182       return -1;
5183   }
5184   {
5185     char device[] = "/dev/sda1";
5186     device[5] = devchar;
5187     char mountpoint[] = "/";
5188     int r;
5189     suppress_error = 0;
5190     r = guestfs_mount (g, device, mountpoint);
5191     if (r == -1)
5192       return -1;
5193   }
5194   /* TestOutputList for umount_all (0) */
5195   {
5196     int r;
5197     suppress_error = 0;
5198     r = guestfs_umount_all (g);
5199     if (r == -1)
5200       return -1;
5201   }
5202   {
5203     char **r;
5204     int i;
5205     suppress_error = 0;
5206     r = guestfs_mounts (g);
5207     if (r == NULL)
5208       return -1;
5209     if (r[0] != NULL) {
5210       fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
5211       print_strings (r);
5212       return -1;
5213     }
5214     for (i = 0; r[i] != NULL; ++i)
5215       free (r[i]);
5216     free (r);
5217   }
5218   return 0;
5219 }
5220
5221 static int test_umount_all_1 (void)
5222 {
5223   /* InitEmpty for umount_all (1) */
5224   {
5225     char device[] = "/dev/sda";
5226     device[5] = devchar;
5227     int r;
5228     suppress_error = 0;
5229     r = guestfs_blockdev_setrw (g, device);
5230     if (r == -1)
5231       return -1;
5232   }
5233   {
5234     int r;
5235     suppress_error = 0;
5236     r = guestfs_umount_all (g);
5237     if (r == -1)
5238       return -1;
5239   }
5240   {
5241     int r;
5242     suppress_error = 0;
5243     r = guestfs_lvm_remove_all (g);
5244     if (r == -1)
5245       return -1;
5246   }
5247   /* TestOutputList for umount_all (1) */
5248   {
5249     char device[] = "/dev/sda";
5250     device[5] = devchar;
5251     char lines_0[] = ",10";
5252     char lines_1[] = ",20";
5253     char lines_2[] = ",";
5254     char *lines[] = {
5255       lines_0,
5256       lines_1,
5257       lines_2,
5258       NULL
5259     };
5260     int r;
5261     suppress_error = 0;
5262     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5263     if (r == -1)
5264       return -1;
5265   }
5266   {
5267     char fstype[] = "ext2";
5268     char device[] = "/dev/sda1";
5269     device[5] = devchar;
5270     int r;
5271     suppress_error = 0;
5272     r = guestfs_mkfs (g, fstype, device);
5273     if (r == -1)
5274       return -1;
5275   }
5276   {
5277     char fstype[] = "ext2";
5278     char device[] = "/dev/sda2";
5279     device[5] = devchar;
5280     int r;
5281     suppress_error = 0;
5282     r = guestfs_mkfs (g, fstype, device);
5283     if (r == -1)
5284       return -1;
5285   }
5286   {
5287     char fstype[] = "ext2";
5288     char device[] = "/dev/sda3";
5289     device[5] = devchar;
5290     int r;
5291     suppress_error = 0;
5292     r = guestfs_mkfs (g, fstype, device);
5293     if (r == -1)
5294       return -1;
5295   }
5296   {
5297     char device[] = "/dev/sda1";
5298     device[5] = devchar;
5299     char mountpoint[] = "/";
5300     int r;
5301     suppress_error = 0;
5302     r = guestfs_mount (g, device, mountpoint);
5303     if (r == -1)
5304       return -1;
5305   }
5306   {
5307     char path[] = "/mp1";
5308     int r;
5309     suppress_error = 0;
5310     r = guestfs_mkdir (g, path);
5311     if (r == -1)
5312       return -1;
5313   }
5314   {
5315     char device[] = "/dev/sda2";
5316     device[5] = devchar;
5317     char mountpoint[] = "/mp1";
5318     int r;
5319     suppress_error = 0;
5320     r = guestfs_mount (g, device, mountpoint);
5321     if (r == -1)
5322       return -1;
5323   }
5324   {
5325     char path[] = "/mp1/mp2";
5326     int r;
5327     suppress_error = 0;
5328     r = guestfs_mkdir (g, path);
5329     if (r == -1)
5330       return -1;
5331   }
5332   {
5333     char device[] = "/dev/sda3";
5334     device[5] = devchar;
5335     char mountpoint[] = "/mp1/mp2";
5336     int r;
5337     suppress_error = 0;
5338     r = guestfs_mount (g, device, mountpoint);
5339     if (r == -1)
5340       return -1;
5341   }
5342   {
5343     char path[] = "/mp1/mp2/mp3";
5344     int r;
5345     suppress_error = 0;
5346     r = guestfs_mkdir (g, path);
5347     if (r == -1)
5348       return -1;
5349   }
5350   {
5351     int r;
5352     suppress_error = 0;
5353     r = guestfs_umount_all (g);
5354     if (r == -1)
5355       return -1;
5356   }
5357   {
5358     char **r;
5359     int i;
5360     suppress_error = 0;
5361     r = guestfs_mounts (g);
5362     if (r == NULL)
5363       return -1;
5364     if (r[0] != NULL) {
5365       fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
5366       print_strings (r);
5367       return -1;
5368     }
5369     for (i = 0; r[i] != NULL; ++i)
5370       free (r[i]);
5371     free (r);
5372   }
5373   return 0;
5374 }
5375
5376 static int test_mounts_0 (void)
5377 {
5378   /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
5379   {
5380     char device[] = "/dev/sda";
5381     device[5] = devchar;
5382     int r;
5383     suppress_error = 0;
5384     r = guestfs_blockdev_setrw (g, device);
5385     if (r == -1)
5386       return -1;
5387   }
5388   {
5389     int r;
5390     suppress_error = 0;
5391     r = guestfs_umount_all (g);
5392     if (r == -1)
5393       return -1;
5394   }
5395   {
5396     int r;
5397     suppress_error = 0;
5398     r = guestfs_lvm_remove_all (g);
5399     if (r == -1)
5400       return -1;
5401   }
5402   {
5403     char device[] = "/dev/sda";
5404     device[5] = devchar;
5405     char lines_0[] = ",";
5406     char *lines[] = {
5407       lines_0,
5408       NULL
5409     };
5410     int r;
5411     suppress_error = 0;
5412     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5413     if (r == -1)
5414       return -1;
5415   }
5416   {
5417     char fstype[] = "ext2";
5418     char device[] = "/dev/sda1";
5419     device[5] = devchar;
5420     int r;
5421     suppress_error = 0;
5422     r = guestfs_mkfs (g, fstype, device);
5423     if (r == -1)
5424       return -1;
5425   }
5426   {
5427     char device[] = "/dev/sda1";
5428     device[5] = devchar;
5429     char mountpoint[] = "/";
5430     int r;
5431     suppress_error = 0;
5432     r = guestfs_mount (g, device, mountpoint);
5433     if (r == -1)
5434       return -1;
5435   }
5436   /* TestOutputList for mounts (0) */
5437   {
5438     char **r;
5439     int i;
5440     suppress_error = 0;
5441     r = guestfs_mounts (g);
5442     if (r == NULL)
5443       return -1;
5444     if (!r[0]) {
5445       fprintf (stderr, "test_mounts_0: short list returned from command\n");
5446       print_strings (r);
5447       return -1;
5448     }
5449     {
5450       char expected[] = "/dev/sda1";
5451       expected[5] = devchar;
5452       if (strcmp (r[0], expected) != 0) {
5453         fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5454         return -1;
5455       }
5456     }
5457     if (r[1] != NULL) {
5458       fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
5459       print_strings (r);
5460       return -1;
5461     }
5462     for (i = 0; r[i] != NULL; ++i)
5463       free (r[i]);
5464     free (r);
5465   }
5466   return 0;
5467 }
5468
5469 static int test_umount_0 (void)
5470 {
5471   /* InitEmpty for umount (0) */
5472   {
5473     char device[] = "/dev/sda";
5474     device[5] = devchar;
5475     int r;
5476     suppress_error = 0;
5477     r = guestfs_blockdev_setrw (g, device);
5478     if (r == -1)
5479       return -1;
5480   }
5481   {
5482     int r;
5483     suppress_error = 0;
5484     r = guestfs_umount_all (g);
5485     if (r == -1)
5486       return -1;
5487   }
5488   {
5489     int r;
5490     suppress_error = 0;
5491     r = guestfs_lvm_remove_all (g);
5492     if (r == -1)
5493       return -1;
5494   }
5495   /* TestOutputList for umount (0) */
5496   {
5497     char device[] = "/dev/sda";
5498     device[5] = devchar;
5499     char lines_0[] = ",";
5500     char *lines[] = {
5501       lines_0,
5502       NULL
5503     };
5504     int r;
5505     suppress_error = 0;
5506     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5507     if (r == -1)
5508       return -1;
5509   }
5510   {
5511     char fstype[] = "ext2";
5512     char device[] = "/dev/sda1";
5513     device[5] = devchar;
5514     int r;
5515     suppress_error = 0;
5516     r = guestfs_mkfs (g, fstype, device);
5517     if (r == -1)
5518       return -1;
5519   }
5520   {
5521     char device[] = "/dev/sda1";
5522     device[5] = devchar;
5523     char mountpoint[] = "/";
5524     int r;
5525     suppress_error = 0;
5526     r = guestfs_mount (g, device, mountpoint);
5527     if (r == -1)
5528       return -1;
5529   }
5530   {
5531     char **r;
5532     int i;
5533     suppress_error = 0;
5534     r = guestfs_mounts (g);
5535     if (r == NULL)
5536       return -1;
5537     if (!r[0]) {
5538       fprintf (stderr, "test_umount_0: short list returned from command\n");
5539       print_strings (r);
5540       return -1;
5541     }
5542     {
5543       char expected[] = "/dev/sda1";
5544       expected[5] = devchar;
5545       if (strcmp (r[0], expected) != 0) {
5546         fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5547         return -1;
5548       }
5549     }
5550     if (r[1] != NULL) {
5551       fprintf (stderr, "test_umount_0: extra elements returned from command\n");
5552       print_strings (r);
5553       return -1;
5554     }
5555     for (i = 0; r[i] != NULL; ++i)
5556       free (r[i]);
5557     free (r);
5558   }
5559   return 0;
5560 }
5561
5562 static int test_umount_1 (void)
5563 {
5564   /* InitEmpty for umount (1) */
5565   {
5566     char device[] = "/dev/sda";
5567     device[5] = devchar;
5568     int r;
5569     suppress_error = 0;
5570     r = guestfs_blockdev_setrw (g, device);
5571     if (r == -1)
5572       return -1;
5573   }
5574   {
5575     int r;
5576     suppress_error = 0;
5577     r = guestfs_umount_all (g);
5578     if (r == -1)
5579       return -1;
5580   }
5581   {
5582     int r;
5583     suppress_error = 0;
5584     r = guestfs_lvm_remove_all (g);
5585     if (r == -1)
5586       return -1;
5587   }
5588   /* TestOutputList for umount (1) */
5589   {
5590     char device[] = "/dev/sda";
5591     device[5] = devchar;
5592     char lines_0[] = ",";
5593     char *lines[] = {
5594       lines_0,
5595       NULL
5596     };
5597     int r;
5598     suppress_error = 0;
5599     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5600     if (r == -1)
5601       return -1;
5602   }
5603   {
5604     char fstype[] = "ext2";
5605     char device[] = "/dev/sda1";
5606     device[5] = devchar;
5607     int r;
5608     suppress_error = 0;
5609     r = guestfs_mkfs (g, fstype, device);
5610     if (r == -1)
5611       return -1;
5612   }
5613   {
5614     char device[] = "/dev/sda1";
5615     device[5] = devchar;
5616     char mountpoint[] = "/";
5617     int r;
5618     suppress_error = 0;
5619     r = guestfs_mount (g, device, mountpoint);
5620     if (r == -1)
5621       return -1;
5622   }
5623   {
5624     char pathordevice[] = "/";
5625     int r;
5626     suppress_error = 0;
5627     r = guestfs_umount (g, pathordevice);
5628     if (r == -1)
5629       return -1;
5630   }
5631   {
5632     char **r;
5633     int i;
5634     suppress_error = 0;
5635     r = guestfs_mounts (g);
5636     if (r == NULL)
5637       return -1;
5638     if (r[0] != NULL) {
5639       fprintf (stderr, "test_umount_1: extra elements returned from command\n");
5640       print_strings (r);
5641       return -1;
5642     }
5643     for (i = 0; r[i] != NULL; ++i)
5644       free (r[i]);
5645     free (r);
5646   }
5647   return 0;
5648 }
5649
5650 static int test_write_file_0 (void)
5651 {
5652   /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
5653   {
5654     char device[] = "/dev/sda";
5655     device[5] = devchar;
5656     int r;
5657     suppress_error = 0;
5658     r = guestfs_blockdev_setrw (g, device);
5659     if (r == -1)
5660       return -1;
5661   }
5662   {
5663     int r;
5664     suppress_error = 0;
5665     r = guestfs_umount_all (g);
5666     if (r == -1)
5667       return -1;
5668   }
5669   {
5670     int r;
5671     suppress_error = 0;
5672     r = guestfs_lvm_remove_all (g);
5673     if (r == -1)
5674       return -1;
5675   }
5676   {
5677     char device[] = "/dev/sda";
5678     device[5] = devchar;
5679     char lines_0[] = ",";
5680     char *lines[] = {
5681       lines_0,
5682       NULL
5683     };
5684     int r;
5685     suppress_error = 0;
5686     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5687     if (r == -1)
5688       return -1;
5689   }
5690   {
5691     char fstype[] = "ext2";
5692     char device[] = "/dev/sda1";
5693     device[5] = devchar;
5694     int r;
5695     suppress_error = 0;
5696     r = guestfs_mkfs (g, fstype, device);
5697     if (r == -1)
5698       return -1;
5699   }
5700   {
5701     char device[] = "/dev/sda1";
5702     device[5] = devchar;
5703     char mountpoint[] = "/";
5704     int r;
5705     suppress_error = 0;
5706     r = guestfs_mount (g, device, mountpoint);
5707     if (r == -1)
5708       return -1;
5709   }
5710   /* TestOutput for write_file (0) */
5711   char expected[] = "new file contents";
5712   {
5713     char path[] = "/new";
5714     char content[] = "new file contents";
5715     int r;
5716     suppress_error = 0;
5717     r = guestfs_write_file (g, path, content, 0);
5718     if (r == -1)
5719       return -1;
5720   }
5721   {
5722     char path[] = "/new";
5723     char *r;
5724     suppress_error = 0;
5725     r = guestfs_cat (g, path);
5726     if (r == NULL)
5727       return -1;
5728     if (strcmp (r, expected) != 0) {
5729       fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
5730       return -1;
5731     }
5732     free (r);
5733   }
5734   return 0;
5735 }
5736
5737 static int test_write_file_1 (void)
5738 {
5739   /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
5740   {
5741     char device[] = "/dev/sda";
5742     device[5] = devchar;
5743     int r;
5744     suppress_error = 0;
5745     r = guestfs_blockdev_setrw (g, device);
5746     if (r == -1)
5747       return -1;
5748   }
5749   {
5750     int r;
5751     suppress_error = 0;
5752     r = guestfs_umount_all (g);
5753     if (r == -1)
5754       return -1;
5755   }
5756   {
5757     int r;
5758     suppress_error = 0;
5759     r = guestfs_lvm_remove_all (g);
5760     if (r == -1)
5761       return -1;
5762   }
5763   {
5764     char device[] = "/dev/sda";
5765     device[5] = devchar;
5766     char lines_0[] = ",";
5767     char *lines[] = {
5768       lines_0,
5769       NULL
5770     };
5771     int r;
5772     suppress_error = 0;
5773     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5774     if (r == -1)
5775       return -1;
5776   }
5777   {
5778     char fstype[] = "ext2";
5779     char device[] = "/dev/sda1";
5780     device[5] = devchar;
5781     int r;
5782     suppress_error = 0;
5783     r = guestfs_mkfs (g, fstype, device);
5784     if (r == -1)
5785       return -1;
5786   }
5787   {
5788     char device[] = "/dev/sda1";
5789     device[5] = devchar;
5790     char mountpoint[] = "/";
5791     int r;
5792     suppress_error = 0;
5793     r = guestfs_mount (g, device, mountpoint);
5794     if (r == -1)
5795       return -1;
5796   }
5797   /* TestOutput for write_file (1) */
5798   char expected[] = "\nnew file contents\n";
5799   {
5800     char path[] = "/new";
5801     char content[] = "\nnew file contents\n";
5802     int r;
5803     suppress_error = 0;
5804     r = guestfs_write_file (g, path, content, 0);
5805     if (r == -1)
5806       return -1;
5807   }
5808   {
5809     char path[] = "/new";
5810     char *r;
5811     suppress_error = 0;
5812     r = guestfs_cat (g, path);
5813     if (r == NULL)
5814       return -1;
5815     if (strcmp (r, expected) != 0) {
5816       fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5817       return -1;
5818     }
5819     free (r);
5820   }
5821   return 0;
5822 }
5823
5824 static int test_write_file_2 (void)
5825 {
5826   /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
5827   {
5828     char device[] = "/dev/sda";
5829     device[5] = devchar;
5830     int r;
5831     suppress_error = 0;
5832     r = guestfs_blockdev_setrw (g, device);
5833     if (r == -1)
5834       return -1;
5835   }
5836   {
5837     int r;
5838     suppress_error = 0;
5839     r = guestfs_umount_all (g);
5840     if (r == -1)
5841       return -1;
5842   }
5843   {
5844     int r;
5845     suppress_error = 0;
5846     r = guestfs_lvm_remove_all (g);
5847     if (r == -1)
5848       return -1;
5849   }
5850   {
5851     char device[] = "/dev/sda";
5852     device[5] = devchar;
5853     char lines_0[] = ",";
5854     char *lines[] = {
5855       lines_0,
5856       NULL
5857     };
5858     int r;
5859     suppress_error = 0;
5860     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5861     if (r == -1)
5862       return -1;
5863   }
5864   {
5865     char fstype[] = "ext2";
5866     char device[] = "/dev/sda1";
5867     device[5] = devchar;
5868     int r;
5869     suppress_error = 0;
5870     r = guestfs_mkfs (g, fstype, device);
5871     if (r == -1)
5872       return -1;
5873   }
5874   {
5875     char device[] = "/dev/sda1";
5876     device[5] = devchar;
5877     char mountpoint[] = "/";
5878     int r;
5879     suppress_error = 0;
5880     r = guestfs_mount (g, device, mountpoint);
5881     if (r == -1)
5882       return -1;
5883   }
5884   /* TestOutput for write_file (2) */
5885   char expected[] = "\n\n";
5886   {
5887     char path[] = "/new";
5888     char content[] = "\n\n";
5889     int r;
5890     suppress_error = 0;
5891     r = guestfs_write_file (g, path, content, 0);
5892     if (r == -1)
5893       return -1;
5894   }
5895   {
5896     char path[] = "/new";
5897     char *r;
5898     suppress_error = 0;
5899     r = guestfs_cat (g, path);
5900     if (r == NULL)
5901       return -1;
5902     if (strcmp (r, expected) != 0) {
5903       fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
5904       return -1;
5905     }
5906     free (r);
5907   }
5908   return 0;
5909 }
5910
5911 static int test_write_file_3 (void)
5912 {
5913   /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
5914   {
5915     char device[] = "/dev/sda";
5916     device[5] = devchar;
5917     int r;
5918     suppress_error = 0;
5919     r = guestfs_blockdev_setrw (g, device);
5920     if (r == -1)
5921       return -1;
5922   }
5923   {
5924     int r;
5925     suppress_error = 0;
5926     r = guestfs_umount_all (g);
5927     if (r == -1)
5928       return -1;
5929   }
5930   {
5931     int r;
5932     suppress_error = 0;
5933     r = guestfs_lvm_remove_all (g);
5934     if (r == -1)
5935       return -1;
5936   }
5937   {
5938     char device[] = "/dev/sda";
5939     device[5] = devchar;
5940     char lines_0[] = ",";
5941     char *lines[] = {
5942       lines_0,
5943       NULL
5944     };
5945     int r;
5946     suppress_error = 0;
5947     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5948     if (r == -1)
5949       return -1;
5950   }
5951   {
5952     char fstype[] = "ext2";
5953     char device[] = "/dev/sda1";
5954     device[5] = devchar;
5955     int r;
5956     suppress_error = 0;
5957     r = guestfs_mkfs (g, fstype, device);
5958     if (r == -1)
5959       return -1;
5960   }
5961   {
5962     char device[] = "/dev/sda1";
5963     device[5] = devchar;
5964     char mountpoint[] = "/";
5965     int r;
5966     suppress_error = 0;
5967     r = guestfs_mount (g, device, mountpoint);
5968     if (r == -1)
5969       return -1;
5970   }
5971   /* TestOutput for write_file (3) */
5972   char expected[] = "";
5973   {
5974     char path[] = "/new";
5975     char content[] = "";
5976     int r;
5977     suppress_error = 0;
5978     r = guestfs_write_file (g, path, content, 0);
5979     if (r == -1)
5980       return -1;
5981   }
5982   {
5983     char path[] = "/new";
5984     char *r;
5985     suppress_error = 0;
5986     r = guestfs_cat (g, path);
5987     if (r == NULL)
5988       return -1;
5989     if (strcmp (r, expected) != 0) {
5990       fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
5991       return -1;
5992     }
5993     free (r);
5994   }
5995   return 0;
5996 }
5997
5998 static int test_write_file_4 (void)
5999 {
6000   /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
6001   {
6002     char device[] = "/dev/sda";
6003     device[5] = devchar;
6004     int r;
6005     suppress_error = 0;
6006     r = guestfs_blockdev_setrw (g, device);
6007     if (r == -1)
6008       return -1;
6009   }
6010   {
6011     int r;
6012     suppress_error = 0;
6013     r = guestfs_umount_all (g);
6014     if (r == -1)
6015       return -1;
6016   }
6017   {
6018     int r;
6019     suppress_error = 0;
6020     r = guestfs_lvm_remove_all (g);
6021     if (r == -1)
6022       return -1;
6023   }
6024   {
6025     char device[] = "/dev/sda";
6026     device[5] = devchar;
6027     char lines_0[] = ",";
6028     char *lines[] = {
6029       lines_0,
6030       NULL
6031     };
6032     int r;
6033     suppress_error = 0;
6034     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6035     if (r == -1)
6036       return -1;
6037   }
6038   {
6039     char fstype[] = "ext2";
6040     char device[] = "/dev/sda1";
6041     device[5] = devchar;
6042     int r;
6043     suppress_error = 0;
6044     r = guestfs_mkfs (g, fstype, device);
6045     if (r == -1)
6046       return -1;
6047   }
6048   {
6049     char device[] = "/dev/sda1";
6050     device[5] = devchar;
6051     char mountpoint[] = "/";
6052     int r;
6053     suppress_error = 0;
6054     r = guestfs_mount (g, device, mountpoint);
6055     if (r == -1)
6056       return -1;
6057   }
6058   /* TestOutput for write_file (4) */
6059   char expected[] = "\n\n\n";
6060   {
6061     char path[] = "/new";
6062     char content[] = "\n\n\n";
6063     int r;
6064     suppress_error = 0;
6065     r = guestfs_write_file (g, path, content, 0);
6066     if (r == -1)
6067       return -1;
6068   }
6069   {
6070     char path[] = "/new";
6071     char *r;
6072     suppress_error = 0;
6073     r = guestfs_cat (g, path);
6074     if (r == NULL)
6075       return -1;
6076     if (strcmp (r, expected) != 0) {
6077       fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
6078       return -1;
6079     }
6080     free (r);
6081   }
6082   return 0;
6083 }
6084
6085 static int test_write_file_5 (void)
6086 {
6087   /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
6088   {
6089     char device[] = "/dev/sda";
6090     device[5] = devchar;
6091     int r;
6092     suppress_error = 0;
6093     r = guestfs_blockdev_setrw (g, device);
6094     if (r == -1)
6095       return -1;
6096   }
6097   {
6098     int r;
6099     suppress_error = 0;
6100     r = guestfs_umount_all (g);
6101     if (r == -1)
6102       return -1;
6103   }
6104   {
6105     int r;
6106     suppress_error = 0;
6107     r = guestfs_lvm_remove_all (g);
6108     if (r == -1)
6109       return -1;
6110   }
6111   {
6112     char device[] = "/dev/sda";
6113     device[5] = devchar;
6114     char lines_0[] = ",";
6115     char *lines[] = {
6116       lines_0,
6117       NULL
6118     };
6119     int r;
6120     suppress_error = 0;
6121     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6122     if (r == -1)
6123       return -1;
6124   }
6125   {
6126     char fstype[] = "ext2";
6127     char device[] = "/dev/sda1";
6128     device[5] = devchar;
6129     int r;
6130     suppress_error = 0;
6131     r = guestfs_mkfs (g, fstype, device);
6132     if (r == -1)
6133       return -1;
6134   }
6135   {
6136     char device[] = "/dev/sda1";
6137     device[5] = devchar;
6138     char mountpoint[] = "/";
6139     int r;
6140     suppress_error = 0;
6141     r = guestfs_mount (g, device, mountpoint);
6142     if (r == -1)
6143       return -1;
6144   }
6145   /* TestOutput for write_file (5) */
6146   char expected[] = "\n";
6147   {
6148     char path[] = "/new";
6149     char content[] = "\n";
6150     int r;
6151     suppress_error = 0;
6152     r = guestfs_write_file (g, path, content, 0);
6153     if (r == -1)
6154       return -1;
6155   }
6156   {
6157     char path[] = "/new";
6158     char *r;
6159     suppress_error = 0;
6160     r = guestfs_cat (g, path);
6161     if (r == NULL)
6162       return -1;
6163     if (strcmp (r, expected) != 0) {
6164       fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
6165       return -1;
6166     }
6167     free (r);
6168   }
6169   return 0;
6170 }
6171
6172 static int test_mkfs_0 (void)
6173 {
6174   /* InitEmpty for mkfs (0) */
6175   {
6176     char device[] = "/dev/sda";
6177     device[5] = devchar;
6178     int r;
6179     suppress_error = 0;
6180     r = guestfs_blockdev_setrw (g, device);
6181     if (r == -1)
6182       return -1;
6183   }
6184   {
6185     int r;
6186     suppress_error = 0;
6187     r = guestfs_umount_all (g);
6188     if (r == -1)
6189       return -1;
6190   }
6191   {
6192     int r;
6193     suppress_error = 0;
6194     r = guestfs_lvm_remove_all (g);
6195     if (r == -1)
6196       return -1;
6197   }
6198   /* TestOutput for mkfs (0) */
6199   char expected[] = "new file contents";
6200   {
6201     char device[] = "/dev/sda";
6202     device[5] = devchar;
6203     char lines_0[] = ",";
6204     char *lines[] = {
6205       lines_0,
6206       NULL
6207     };
6208     int r;
6209     suppress_error = 0;
6210     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6211     if (r == -1)
6212       return -1;
6213   }
6214   {
6215     char fstype[] = "ext2";
6216     char device[] = "/dev/sda1";
6217     device[5] = devchar;
6218     int r;
6219     suppress_error = 0;
6220     r = guestfs_mkfs (g, fstype, device);
6221     if (r == -1)
6222       return -1;
6223   }
6224   {
6225     char device[] = "/dev/sda1";
6226     device[5] = devchar;
6227     char mountpoint[] = "/";
6228     int r;
6229     suppress_error = 0;
6230     r = guestfs_mount (g, device, mountpoint);
6231     if (r == -1)
6232       return -1;
6233   }
6234   {
6235     char path[] = "/new";
6236     char content[] = "new file contents";
6237     int r;
6238     suppress_error = 0;
6239     r = guestfs_write_file (g, path, content, 0);
6240     if (r == -1)
6241       return -1;
6242   }
6243   {
6244     char path[] = "/new";
6245     char *r;
6246     suppress_error = 0;
6247     r = guestfs_cat (g, path);
6248     if (r == NULL)
6249       return -1;
6250     if (strcmp (r, expected) != 0) {
6251       fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
6252       return -1;
6253     }
6254     free (r);
6255   }
6256   return 0;
6257 }
6258
6259 static int test_lvcreate_0 (void)
6260 {
6261   /* InitEmpty for lvcreate (0) */
6262   {
6263     char device[] = "/dev/sda";
6264     device[5] = devchar;
6265     int r;
6266     suppress_error = 0;
6267     r = guestfs_blockdev_setrw (g, device);
6268     if (r == -1)
6269       return -1;
6270   }
6271   {
6272     int r;
6273     suppress_error = 0;
6274     r = guestfs_umount_all (g);
6275     if (r == -1)
6276       return -1;
6277   }
6278   {
6279     int r;
6280     suppress_error = 0;
6281     r = guestfs_lvm_remove_all (g);
6282     if (r == -1)
6283       return -1;
6284   }
6285   /* TestOutputList for lvcreate (0) */
6286   {
6287     char device[] = "/dev/sda";
6288     device[5] = devchar;
6289     char lines_0[] = ",10";
6290     char lines_1[] = ",20";
6291     char lines_2[] = ",";
6292     char *lines[] = {
6293       lines_0,
6294       lines_1,
6295       lines_2,
6296       NULL
6297     };
6298     int r;
6299     suppress_error = 0;
6300     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6301     if (r == -1)
6302       return -1;
6303   }
6304   {
6305     char device[] = "/dev/sda1";
6306     device[5] = devchar;
6307     int r;
6308     suppress_error = 0;
6309     r = guestfs_pvcreate (g, device);
6310     if (r == -1)
6311       return -1;
6312   }
6313   {
6314     char device[] = "/dev/sda2";
6315     device[5] = devchar;
6316     int r;
6317     suppress_error = 0;
6318     r = guestfs_pvcreate (g, device);
6319     if (r == -1)
6320       return -1;
6321   }
6322   {
6323     char device[] = "/dev/sda3";
6324     device[5] = devchar;
6325     int r;
6326     suppress_error = 0;
6327     r = guestfs_pvcreate (g, device);
6328     if (r == -1)
6329       return -1;
6330   }
6331   {
6332     char volgroup[] = "VG1";
6333     char physvols_0[] = "/dev/sda1";
6334     physvols_0[5] = devchar;
6335     char physvols_1[] = "/dev/sda2";
6336     physvols_1[5] = devchar;
6337     char *physvols[] = {
6338       physvols_0,
6339       physvols_1,
6340       NULL
6341     };
6342     int r;
6343     suppress_error = 0;
6344     r = guestfs_vgcreate (g, volgroup, physvols);
6345     if (r == -1)
6346       return -1;
6347   }
6348   {
6349     char volgroup[] = "VG2";
6350     char physvols_0[] = "/dev/sda3";
6351     physvols_0[5] = devchar;
6352     char *physvols[] = {
6353       physvols_0,
6354       NULL
6355     };
6356     int r;
6357     suppress_error = 0;
6358     r = guestfs_vgcreate (g, volgroup, physvols);
6359     if (r == -1)
6360       return -1;
6361   }
6362   {
6363     char logvol[] = "LV1";
6364     char volgroup[] = "VG1";
6365     int r;
6366     suppress_error = 0;
6367     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6368     if (r == -1)
6369       return -1;
6370   }
6371   {
6372     char logvol[] = "LV2";
6373     char volgroup[] = "VG1";
6374     int r;
6375     suppress_error = 0;
6376     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6377     if (r == -1)
6378       return -1;
6379   }
6380   {
6381     char logvol[] = "LV3";
6382     char volgroup[] = "VG2";
6383     int r;
6384     suppress_error = 0;
6385     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6386     if (r == -1)
6387       return -1;
6388   }
6389   {
6390     char logvol[] = "LV4";
6391     char volgroup[] = "VG2";
6392     int r;
6393     suppress_error = 0;
6394     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6395     if (r == -1)
6396       return -1;
6397   }
6398   {
6399     char logvol[] = "LV5";
6400     char volgroup[] = "VG2";
6401     int r;
6402     suppress_error = 0;
6403     r = guestfs_lvcreate (g, logvol, volgroup, 50);
6404     if (r == -1)
6405       return -1;
6406   }
6407   {
6408     char **r;
6409     int i;
6410     suppress_error = 0;
6411     r = guestfs_lvs (g);
6412     if (r == NULL)
6413       return -1;
6414     if (!r[0]) {
6415       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6416       print_strings (r);
6417       return -1;
6418     }
6419     {
6420       char expected[] = "/dev/VG1/LV1";
6421       if (strcmp (r[0], expected) != 0) {
6422         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6423         return -1;
6424       }
6425     }
6426     if (!r[1]) {
6427       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6428       print_strings (r);
6429       return -1;
6430     }
6431     {
6432       char expected[] = "/dev/VG1/LV2";
6433       if (strcmp (r[1], expected) != 0) {
6434         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6435         return -1;
6436       }
6437     }
6438     if (!r[2]) {
6439       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6440       print_strings (r);
6441       return -1;
6442     }
6443     {
6444       char expected[] = "/dev/VG2/LV3";
6445       if (strcmp (r[2], expected) != 0) {
6446         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6447         return -1;
6448       }
6449     }
6450     if (!r[3]) {
6451       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6452       print_strings (r);
6453       return -1;
6454     }
6455     {
6456       char expected[] = "/dev/VG2/LV4";
6457       if (strcmp (r[3], expected) != 0) {
6458         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
6459         return -1;
6460       }
6461     }
6462     if (!r[4]) {
6463       fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6464       print_strings (r);
6465       return -1;
6466     }
6467     {
6468       char expected[] = "/dev/VG2/LV5";
6469       if (strcmp (r[4], expected) != 0) {
6470         fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
6471         return -1;
6472       }
6473     }
6474     if (r[5] != NULL) {
6475       fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
6476       print_strings (r);
6477       return -1;
6478     }
6479     for (i = 0; r[i] != NULL; ++i)
6480       free (r[i]);
6481     free (r);
6482   }
6483   return 0;
6484 }
6485
6486 static int test_vgcreate_0 (void)
6487 {
6488   /* InitEmpty for vgcreate (0) */
6489   {
6490     char device[] = "/dev/sda";
6491     device[5] = devchar;
6492     int r;
6493     suppress_error = 0;
6494     r = guestfs_blockdev_setrw (g, device);
6495     if (r == -1)
6496       return -1;
6497   }
6498   {
6499     int r;
6500     suppress_error = 0;
6501     r = guestfs_umount_all (g);
6502     if (r == -1)
6503       return -1;
6504   }
6505   {
6506     int r;
6507     suppress_error = 0;
6508     r = guestfs_lvm_remove_all (g);
6509     if (r == -1)
6510       return -1;
6511   }
6512   /* TestOutputList for vgcreate (0) */
6513   {
6514     char device[] = "/dev/sda";
6515     device[5] = devchar;
6516     char lines_0[] = ",10";
6517     char lines_1[] = ",20";
6518     char lines_2[] = ",";
6519     char *lines[] = {
6520       lines_0,
6521       lines_1,
6522       lines_2,
6523       NULL
6524     };
6525     int r;
6526     suppress_error = 0;
6527     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6528     if (r == -1)
6529       return -1;
6530   }
6531   {
6532     char device[] = "/dev/sda1";
6533     device[5] = devchar;
6534     int r;
6535     suppress_error = 0;
6536     r = guestfs_pvcreate (g, device);
6537     if (r == -1)
6538       return -1;
6539   }
6540   {
6541     char device[] = "/dev/sda2";
6542     device[5] = devchar;
6543     int r;
6544     suppress_error = 0;
6545     r = guestfs_pvcreate (g, device);
6546     if (r == -1)
6547       return -1;
6548   }
6549   {
6550     char device[] = "/dev/sda3";
6551     device[5] = devchar;
6552     int r;
6553     suppress_error = 0;
6554     r = guestfs_pvcreate (g, device);
6555     if (r == -1)
6556       return -1;
6557   }
6558   {
6559     char volgroup[] = "VG1";
6560     char physvols_0[] = "/dev/sda1";
6561     physvols_0[5] = devchar;
6562     char physvols_1[] = "/dev/sda2";
6563     physvols_1[5] = devchar;
6564     char *physvols[] = {
6565       physvols_0,
6566       physvols_1,
6567       NULL
6568     };
6569     int r;
6570     suppress_error = 0;
6571     r = guestfs_vgcreate (g, volgroup, physvols);
6572     if (r == -1)
6573       return -1;
6574   }
6575   {
6576     char volgroup[] = "VG2";
6577     char physvols_0[] = "/dev/sda3";
6578     physvols_0[5] = devchar;
6579     char *physvols[] = {
6580       physvols_0,
6581       NULL
6582     };
6583     int r;
6584     suppress_error = 0;
6585     r = guestfs_vgcreate (g, volgroup, physvols);
6586     if (r == -1)
6587       return -1;
6588   }
6589   {
6590     char **r;
6591     int i;
6592     suppress_error = 0;
6593     r = guestfs_vgs (g);
6594     if (r == NULL)
6595       return -1;
6596     if (!r[0]) {
6597       fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6598       print_strings (r);
6599       return -1;
6600     }
6601     {
6602       char expected[] = "VG1";
6603       if (strcmp (r[0], expected) != 0) {
6604         fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6605         return -1;
6606       }
6607     }
6608     if (!r[1]) {
6609       fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6610       print_strings (r);
6611       return -1;
6612     }
6613     {
6614       char expected[] = "VG2";
6615       if (strcmp (r[1], expected) != 0) {
6616         fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6617         return -1;
6618       }
6619     }
6620     if (r[2] != NULL) {
6621       fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
6622       print_strings (r);
6623       return -1;
6624     }
6625     for (i = 0; r[i] != NULL; ++i)
6626       free (r[i]);
6627     free (r);
6628   }
6629   return 0;
6630 }
6631
6632 static int test_pvcreate_0 (void)
6633 {
6634   /* InitEmpty for pvcreate (0) */
6635   {
6636     char device[] = "/dev/sda";
6637     device[5] = devchar;
6638     int r;
6639     suppress_error = 0;
6640     r = guestfs_blockdev_setrw (g, device);
6641     if (r == -1)
6642       return -1;
6643   }
6644   {
6645     int r;
6646     suppress_error = 0;
6647     r = guestfs_umount_all (g);
6648     if (r == -1)
6649       return -1;
6650   }
6651   {
6652     int r;
6653     suppress_error = 0;
6654     r = guestfs_lvm_remove_all (g);
6655     if (r == -1)
6656       return -1;
6657   }
6658   /* TestOutputList for pvcreate (0) */
6659   {
6660     char device[] = "/dev/sda";
6661     device[5] = devchar;
6662     char lines_0[] = ",10";
6663     char lines_1[] = ",20";
6664     char lines_2[] = ",";
6665     char *lines[] = {
6666       lines_0,
6667       lines_1,
6668       lines_2,
6669       NULL
6670     };
6671     int r;
6672     suppress_error = 0;
6673     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6674     if (r == -1)
6675       return -1;
6676   }
6677   {
6678     char device[] = "/dev/sda1";
6679     device[5] = devchar;
6680     int r;
6681     suppress_error = 0;
6682     r = guestfs_pvcreate (g, device);
6683     if (r == -1)
6684       return -1;
6685   }
6686   {
6687     char device[] = "/dev/sda2";
6688     device[5] = devchar;
6689     int r;
6690     suppress_error = 0;
6691     r = guestfs_pvcreate (g, device);
6692     if (r == -1)
6693       return -1;
6694   }
6695   {
6696     char device[] = "/dev/sda3";
6697     device[5] = devchar;
6698     int r;
6699     suppress_error = 0;
6700     r = guestfs_pvcreate (g, device);
6701     if (r == -1)
6702       return -1;
6703   }
6704   {
6705     char **r;
6706     int i;
6707     suppress_error = 0;
6708     r = guestfs_pvs (g);
6709     if (r == NULL)
6710       return -1;
6711     if (!r[0]) {
6712       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6713       print_strings (r);
6714       return -1;
6715     }
6716     {
6717       char expected[] = "/dev/sda1";
6718       expected[5] = devchar;
6719       if (strcmp (r[0], expected) != 0) {
6720         fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6721         return -1;
6722       }
6723     }
6724     if (!r[1]) {
6725       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6726       print_strings (r);
6727       return -1;
6728     }
6729     {
6730       char expected[] = "/dev/sda2";
6731       expected[5] = devchar;
6732       if (strcmp (r[1], expected) != 0) {
6733         fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6734         return -1;
6735       }
6736     }
6737     if (!r[2]) {
6738       fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6739       print_strings (r);
6740       return -1;
6741     }
6742     {
6743       char expected[] = "/dev/sda3";
6744       expected[5] = devchar;
6745       if (strcmp (r[2], expected) != 0) {
6746         fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6747         return -1;
6748       }
6749     }
6750     if (r[3] != NULL) {
6751       fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
6752       print_strings (r);
6753       return -1;
6754     }
6755     for (i = 0; r[i] != NULL; ++i)
6756       free (r[i]);
6757     free (r);
6758   }
6759   return 0;
6760 }
6761
6762 static int test_is_dir_0 (void)
6763 {
6764   /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
6765   {
6766     char device[] = "/dev/sda";
6767     device[5] = devchar;
6768     int r;
6769     suppress_error = 0;
6770     r = guestfs_blockdev_setrw (g, device);
6771     if (r == -1)
6772       return -1;
6773   }
6774   {
6775     int r;
6776     suppress_error = 0;
6777     r = guestfs_umount_all (g);
6778     if (r == -1)
6779       return -1;
6780   }
6781   {
6782     int r;
6783     suppress_error = 0;
6784     r = guestfs_lvm_remove_all (g);
6785     if (r == -1)
6786       return -1;
6787   }
6788   {
6789     char device[] = "/dev/sda";
6790     device[5] = devchar;
6791     char lines_0[] = ",";
6792     char *lines[] = {
6793       lines_0,
6794       NULL
6795     };
6796     int r;
6797     suppress_error = 0;
6798     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6799     if (r == -1)
6800       return -1;
6801   }
6802   {
6803     char fstype[] = "ext2";
6804     char device[] = "/dev/sda1";
6805     device[5] = devchar;
6806     int r;
6807     suppress_error = 0;
6808     r = guestfs_mkfs (g, fstype, device);
6809     if (r == -1)
6810       return -1;
6811   }
6812   {
6813     char device[] = "/dev/sda1";
6814     device[5] = devchar;
6815     char mountpoint[] = "/";
6816     int r;
6817     suppress_error = 0;
6818     r = guestfs_mount (g, device, mountpoint);
6819     if (r == -1)
6820       return -1;
6821   }
6822   /* TestOutputFalse for is_dir (0) */
6823   {
6824     char path[] = "/new";
6825     int r;
6826     suppress_error = 0;
6827     r = guestfs_touch (g, path);
6828     if (r == -1)
6829       return -1;
6830   }
6831   {
6832     char path[] = "/new";
6833     int r;
6834     suppress_error = 0;
6835     r = guestfs_is_dir (g, path);
6836     if (r == -1)
6837       return -1;
6838     if (r) {
6839       fprintf (stderr, "test_is_dir_0: expected false, got true\n");
6840       return -1;
6841     }
6842   }
6843   return 0;
6844 }
6845
6846 static int test_is_dir_1 (void)
6847 {
6848   /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
6849   {
6850     char device[] = "/dev/sda";
6851     device[5] = devchar;
6852     int r;
6853     suppress_error = 0;
6854     r = guestfs_blockdev_setrw (g, device);
6855     if (r == -1)
6856       return -1;
6857   }
6858   {
6859     int r;
6860     suppress_error = 0;
6861     r = guestfs_umount_all (g);
6862     if (r == -1)
6863       return -1;
6864   }
6865   {
6866     int r;
6867     suppress_error = 0;
6868     r = guestfs_lvm_remove_all (g);
6869     if (r == -1)
6870       return -1;
6871   }
6872   {
6873     char device[] = "/dev/sda";
6874     device[5] = devchar;
6875     char lines_0[] = ",";
6876     char *lines[] = {
6877       lines_0,
6878       NULL
6879     };
6880     int r;
6881     suppress_error = 0;
6882     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6883     if (r == -1)
6884       return -1;
6885   }
6886   {
6887     char fstype[] = "ext2";
6888     char device[] = "/dev/sda1";
6889     device[5] = devchar;
6890     int r;
6891     suppress_error = 0;
6892     r = guestfs_mkfs (g, fstype, device);
6893     if (r == -1)
6894       return -1;
6895   }
6896   {
6897     char device[] = "/dev/sda1";
6898     device[5] = devchar;
6899     char mountpoint[] = "/";
6900     int r;
6901     suppress_error = 0;
6902     r = guestfs_mount (g, device, mountpoint);
6903     if (r == -1)
6904       return -1;
6905   }
6906   /* TestOutputTrue for is_dir (1) */
6907   {
6908     char path[] = "/new";
6909     int r;
6910     suppress_error = 0;
6911     r = guestfs_mkdir (g, path);
6912     if (r == -1)
6913       return -1;
6914   }
6915   {
6916     char path[] = "/new";
6917     int r;
6918     suppress_error = 0;
6919     r = guestfs_is_dir (g, path);
6920     if (r == -1)
6921       return -1;
6922     if (!r) {
6923       fprintf (stderr, "test_is_dir_1: expected true, got false\n");
6924       return -1;
6925     }
6926   }
6927   return 0;
6928 }
6929
6930 static int test_is_file_0 (void)
6931 {
6932   /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
6933   {
6934     char device[] = "/dev/sda";
6935     device[5] = devchar;
6936     int r;
6937     suppress_error = 0;
6938     r = guestfs_blockdev_setrw (g, device);
6939     if (r == -1)
6940       return -1;
6941   }
6942   {
6943     int r;
6944     suppress_error = 0;
6945     r = guestfs_umount_all (g);
6946     if (r == -1)
6947       return -1;
6948   }
6949   {
6950     int r;
6951     suppress_error = 0;
6952     r = guestfs_lvm_remove_all (g);
6953     if (r == -1)
6954       return -1;
6955   }
6956   {
6957     char device[] = "/dev/sda";
6958     device[5] = devchar;
6959     char lines_0[] = ",";
6960     char *lines[] = {
6961       lines_0,
6962       NULL
6963     };
6964     int r;
6965     suppress_error = 0;
6966     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6967     if (r == -1)
6968       return -1;
6969   }
6970   {
6971     char fstype[] = "ext2";
6972     char device[] = "/dev/sda1";
6973     device[5] = devchar;
6974     int r;
6975     suppress_error = 0;
6976     r = guestfs_mkfs (g, fstype, device);
6977     if (r == -1)
6978       return -1;
6979   }
6980   {
6981     char device[] = "/dev/sda1";
6982     device[5] = devchar;
6983     char mountpoint[] = "/";
6984     int r;
6985     suppress_error = 0;
6986     r = guestfs_mount (g, device, mountpoint);
6987     if (r == -1)
6988       return -1;
6989   }
6990   /* TestOutputTrue for is_file (0) */
6991   {
6992     char path[] = "/new";
6993     int r;
6994     suppress_error = 0;
6995     r = guestfs_touch (g, path);
6996     if (r == -1)
6997       return -1;
6998   }
6999   {
7000     char path[] = "/new";
7001     int r;
7002     suppress_error = 0;
7003     r = guestfs_is_file (g, path);
7004     if (r == -1)
7005       return -1;
7006     if (!r) {
7007       fprintf (stderr, "test_is_file_0: expected true, got false\n");
7008       return -1;
7009     }
7010   }
7011   return 0;
7012 }
7013
7014 static int test_is_file_1 (void)
7015 {
7016   /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
7017   {
7018     char device[] = "/dev/sda";
7019     device[5] = devchar;
7020     int r;
7021     suppress_error = 0;
7022     r = guestfs_blockdev_setrw (g, device);
7023     if (r == -1)
7024       return -1;
7025   }
7026   {
7027     int r;
7028     suppress_error = 0;
7029     r = guestfs_umount_all (g);
7030     if (r == -1)
7031       return -1;
7032   }
7033   {
7034     int r;
7035     suppress_error = 0;
7036     r = guestfs_lvm_remove_all (g);
7037     if (r == -1)
7038       return -1;
7039   }
7040   {
7041     char device[] = "/dev/sda";
7042     device[5] = devchar;
7043     char lines_0[] = ",";
7044     char *lines[] = {
7045       lines_0,
7046       NULL
7047     };
7048     int r;
7049     suppress_error = 0;
7050     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7051     if (r == -1)
7052       return -1;
7053   }
7054   {
7055     char fstype[] = "ext2";
7056     char device[] = "/dev/sda1";
7057     device[5] = devchar;
7058     int r;
7059     suppress_error = 0;
7060     r = guestfs_mkfs (g, fstype, device);
7061     if (r == -1)
7062       return -1;
7063   }
7064   {
7065     char device[] = "/dev/sda1";
7066     device[5] = devchar;
7067     char mountpoint[] = "/";
7068     int r;
7069     suppress_error = 0;
7070     r = guestfs_mount (g, device, mountpoint);
7071     if (r == -1)
7072       return -1;
7073   }
7074   /* TestOutputFalse for is_file (1) */
7075   {
7076     char path[] = "/new";
7077     int r;
7078     suppress_error = 0;
7079     r = guestfs_mkdir (g, path);
7080     if (r == -1)
7081       return -1;
7082   }
7083   {
7084     char path[] = "/new";
7085     int r;
7086     suppress_error = 0;
7087     r = guestfs_is_file (g, path);
7088     if (r == -1)
7089       return -1;
7090     if (r) {
7091       fprintf (stderr, "test_is_file_1: expected false, got true\n");
7092       return -1;
7093     }
7094   }
7095   return 0;
7096 }
7097
7098 static int test_exists_0 (void)
7099 {
7100   /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
7101   {
7102     char device[] = "/dev/sda";
7103     device[5] = devchar;
7104     int r;
7105     suppress_error = 0;
7106     r = guestfs_blockdev_setrw (g, device);
7107     if (r == -1)
7108       return -1;
7109   }
7110   {
7111     int r;
7112     suppress_error = 0;
7113     r = guestfs_umount_all (g);
7114     if (r == -1)
7115       return -1;
7116   }
7117   {
7118     int r;
7119     suppress_error = 0;
7120     r = guestfs_lvm_remove_all (g);
7121     if (r == -1)
7122       return -1;
7123   }
7124   {
7125     char device[] = "/dev/sda";
7126     device[5] = devchar;
7127     char lines_0[] = ",";
7128     char *lines[] = {
7129       lines_0,
7130       NULL
7131     };
7132     int r;
7133     suppress_error = 0;
7134     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7135     if (r == -1)
7136       return -1;
7137   }
7138   {
7139     char fstype[] = "ext2";
7140     char device[] = "/dev/sda1";
7141     device[5] = devchar;
7142     int r;
7143     suppress_error = 0;
7144     r = guestfs_mkfs (g, fstype, device);
7145     if (r == -1)
7146       return -1;
7147   }
7148   {
7149     char device[] = "/dev/sda1";
7150     device[5] = devchar;
7151     char mountpoint[] = "/";
7152     int r;
7153     suppress_error = 0;
7154     r = guestfs_mount (g, device, mountpoint);
7155     if (r == -1)
7156       return -1;
7157   }
7158   /* TestOutputTrue for exists (0) */
7159   {
7160     char path[] = "/new";
7161     int r;
7162     suppress_error = 0;
7163     r = guestfs_touch (g, path);
7164     if (r == -1)
7165       return -1;
7166   }
7167   {
7168     char path[] = "/new";
7169     int r;
7170     suppress_error = 0;
7171     r = guestfs_exists (g, path);
7172     if (r == -1)
7173       return -1;
7174     if (!r) {
7175       fprintf (stderr, "test_exists_0: expected true, got false\n");
7176       return -1;
7177     }
7178   }
7179   return 0;
7180 }
7181
7182 static int test_exists_1 (void)
7183 {
7184   /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
7185   {
7186     char device[] = "/dev/sda";
7187     device[5] = devchar;
7188     int r;
7189     suppress_error = 0;
7190     r = guestfs_blockdev_setrw (g, device);
7191     if (r == -1)
7192       return -1;
7193   }
7194   {
7195     int r;
7196     suppress_error = 0;
7197     r = guestfs_umount_all (g);
7198     if (r == -1)
7199       return -1;
7200   }
7201   {
7202     int r;
7203     suppress_error = 0;
7204     r = guestfs_lvm_remove_all (g);
7205     if (r == -1)
7206       return -1;
7207   }
7208   {
7209     char device[] = "/dev/sda";
7210     device[5] = devchar;
7211     char lines_0[] = ",";
7212     char *lines[] = {
7213       lines_0,
7214       NULL
7215     };
7216     int r;
7217     suppress_error = 0;
7218     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7219     if (r == -1)
7220       return -1;
7221   }
7222   {
7223     char fstype[] = "ext2";
7224     char device[] = "/dev/sda1";
7225     device[5] = devchar;
7226     int r;
7227     suppress_error = 0;
7228     r = guestfs_mkfs (g, fstype, device);
7229     if (r == -1)
7230       return -1;
7231   }
7232   {
7233     char device[] = "/dev/sda1";
7234     device[5] = devchar;
7235     char mountpoint[] = "/";
7236     int r;
7237     suppress_error = 0;
7238     r = guestfs_mount (g, device, mountpoint);
7239     if (r == -1)
7240       return -1;
7241   }
7242   /* TestOutputTrue for exists (1) */
7243   {
7244     char path[] = "/new";
7245     int r;
7246     suppress_error = 0;
7247     r = guestfs_mkdir (g, path);
7248     if (r == -1)
7249       return -1;
7250   }
7251   {
7252     char path[] = "/new";
7253     int r;
7254     suppress_error = 0;
7255     r = guestfs_exists (g, path);
7256     if (r == -1)
7257       return -1;
7258     if (!r) {
7259       fprintf (stderr, "test_exists_1: expected true, got false\n");
7260       return -1;
7261     }
7262   }
7263   return 0;
7264 }
7265
7266 static int test_mkdir_p_0 (void)
7267 {
7268   /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
7269   {
7270     char device[] = "/dev/sda";
7271     device[5] = devchar;
7272     int r;
7273     suppress_error = 0;
7274     r = guestfs_blockdev_setrw (g, device);
7275     if (r == -1)
7276       return -1;
7277   }
7278   {
7279     int r;
7280     suppress_error = 0;
7281     r = guestfs_umount_all (g);
7282     if (r == -1)
7283       return -1;
7284   }
7285   {
7286     int r;
7287     suppress_error = 0;
7288     r = guestfs_lvm_remove_all (g);
7289     if (r == -1)
7290       return -1;
7291   }
7292   {
7293     char device[] = "/dev/sda";
7294     device[5] = devchar;
7295     char lines_0[] = ",";
7296     char *lines[] = {
7297       lines_0,
7298       NULL
7299     };
7300     int r;
7301     suppress_error = 0;
7302     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7303     if (r == -1)
7304       return -1;
7305   }
7306   {
7307     char fstype[] = "ext2";
7308     char device[] = "/dev/sda1";
7309     device[5] = devchar;
7310     int r;
7311     suppress_error = 0;
7312     r = guestfs_mkfs (g, fstype, device);
7313     if (r == -1)
7314       return -1;
7315   }
7316   {
7317     char device[] = "/dev/sda1";
7318     device[5] = devchar;
7319     char mountpoint[] = "/";
7320     int r;
7321     suppress_error = 0;
7322     r = guestfs_mount (g, device, mountpoint);
7323     if (r == -1)
7324       return -1;
7325   }
7326   /* TestOutputTrue for mkdir_p (0) */
7327   {
7328     char path[] = "/new/foo/bar";
7329     int r;
7330     suppress_error = 0;
7331     r = guestfs_mkdir_p (g, path);
7332     if (r == -1)
7333       return -1;
7334   }
7335   {
7336     char path[] = "/new/foo/bar";
7337     int r;
7338     suppress_error = 0;
7339     r = guestfs_is_dir (g, path);
7340     if (r == -1)
7341       return -1;
7342     if (!r) {
7343       fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
7344       return -1;
7345     }
7346   }
7347   return 0;
7348 }
7349
7350 static int test_mkdir_p_1 (void)
7351 {
7352   /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
7353   {
7354     char device[] = "/dev/sda";
7355     device[5] = devchar;
7356     int r;
7357     suppress_error = 0;
7358     r = guestfs_blockdev_setrw (g, device);
7359     if (r == -1)
7360       return -1;
7361   }
7362   {
7363     int r;
7364     suppress_error = 0;
7365     r = guestfs_umount_all (g);
7366     if (r == -1)
7367       return -1;
7368   }
7369   {
7370     int r;
7371     suppress_error = 0;
7372     r = guestfs_lvm_remove_all (g);
7373     if (r == -1)
7374       return -1;
7375   }
7376   {
7377     char device[] = "/dev/sda";
7378     device[5] = devchar;
7379     char lines_0[] = ",";
7380     char *lines[] = {
7381       lines_0,
7382       NULL
7383     };
7384     int r;
7385     suppress_error = 0;
7386     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7387     if (r == -1)
7388       return -1;
7389   }
7390   {
7391     char fstype[] = "ext2";
7392     char device[] = "/dev/sda1";
7393     device[5] = devchar;
7394     int r;
7395     suppress_error = 0;
7396     r = guestfs_mkfs (g, fstype, device);
7397     if (r == -1)
7398       return -1;
7399   }
7400   {
7401     char device[] = "/dev/sda1";
7402     device[5] = devchar;
7403     char mountpoint[] = "/";
7404     int r;
7405     suppress_error = 0;
7406     r = guestfs_mount (g, device, mountpoint);
7407     if (r == -1)
7408       return -1;
7409   }
7410   /* TestOutputTrue for mkdir_p (1) */
7411   {
7412     char path[] = "/new/foo/bar";
7413     int r;
7414     suppress_error = 0;
7415     r = guestfs_mkdir_p (g, path);
7416     if (r == -1)
7417       return -1;
7418   }
7419   {
7420     char path[] = "/new/foo";
7421     int r;
7422     suppress_error = 0;
7423     r = guestfs_is_dir (g, path);
7424     if (r == -1)
7425       return -1;
7426     if (!r) {
7427       fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
7428       return -1;
7429     }
7430   }
7431   return 0;
7432 }
7433
7434 static int test_mkdir_p_2 (void)
7435 {
7436   /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
7437   {
7438     char device[] = "/dev/sda";
7439     device[5] = devchar;
7440     int r;
7441     suppress_error = 0;
7442     r = guestfs_blockdev_setrw (g, device);
7443     if (r == -1)
7444       return -1;
7445   }
7446   {
7447     int r;
7448     suppress_error = 0;
7449     r = guestfs_umount_all (g);
7450     if (r == -1)
7451       return -1;
7452   }
7453   {
7454     int r;
7455     suppress_error = 0;
7456     r = guestfs_lvm_remove_all (g);
7457     if (r == -1)
7458       return -1;
7459   }
7460   {
7461     char device[] = "/dev/sda";
7462     device[5] = devchar;
7463     char lines_0[] = ",";
7464     char *lines[] = {
7465       lines_0,
7466       NULL
7467     };
7468     int r;
7469     suppress_error = 0;
7470     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7471     if (r == -1)
7472       return -1;
7473   }
7474   {
7475     char fstype[] = "ext2";
7476     char device[] = "/dev/sda1";
7477     device[5] = devchar;
7478     int r;
7479     suppress_error = 0;
7480     r = guestfs_mkfs (g, fstype, device);
7481     if (r == -1)
7482       return -1;
7483   }
7484   {
7485     char device[] = "/dev/sda1";
7486     device[5] = devchar;
7487     char mountpoint[] = "/";
7488     int r;
7489     suppress_error = 0;
7490     r = guestfs_mount (g, device, mountpoint);
7491     if (r == -1)
7492       return -1;
7493   }
7494   /* TestOutputTrue for mkdir_p (2) */
7495   {
7496     char path[] = "/new/foo/bar";
7497     int r;
7498     suppress_error = 0;
7499     r = guestfs_mkdir_p (g, path);
7500     if (r == -1)
7501       return -1;
7502   }
7503   {
7504     char path[] = "/new";
7505     int r;
7506     suppress_error = 0;
7507     r = guestfs_is_dir (g, path);
7508     if (r == -1)
7509       return -1;
7510     if (!r) {
7511       fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
7512       return -1;
7513     }
7514   }
7515   return 0;
7516 }
7517
7518 static int test_mkdir_0 (void)
7519 {
7520   /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
7521   {
7522     char device[] = "/dev/sda";
7523     device[5] = devchar;
7524     int r;
7525     suppress_error = 0;
7526     r = guestfs_blockdev_setrw (g, device);
7527     if (r == -1)
7528       return -1;
7529   }
7530   {
7531     int r;
7532     suppress_error = 0;
7533     r = guestfs_umount_all (g);
7534     if (r == -1)
7535       return -1;
7536   }
7537   {
7538     int r;
7539     suppress_error = 0;
7540     r = guestfs_lvm_remove_all (g);
7541     if (r == -1)
7542       return -1;
7543   }
7544   {
7545     char device[] = "/dev/sda";
7546     device[5] = devchar;
7547     char lines_0[] = ",";
7548     char *lines[] = {
7549       lines_0,
7550       NULL
7551     };
7552     int r;
7553     suppress_error = 0;
7554     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7555     if (r == -1)
7556       return -1;
7557   }
7558   {
7559     char fstype[] = "ext2";
7560     char device[] = "/dev/sda1";
7561     device[5] = devchar;
7562     int r;
7563     suppress_error = 0;
7564     r = guestfs_mkfs (g, fstype, device);
7565     if (r == -1)
7566       return -1;
7567   }
7568   {
7569     char device[] = "/dev/sda1";
7570     device[5] = devchar;
7571     char mountpoint[] = "/";
7572     int r;
7573     suppress_error = 0;
7574     r = guestfs_mount (g, device, mountpoint);
7575     if (r == -1)
7576       return -1;
7577   }
7578   /* TestOutputTrue for mkdir (0) */
7579   {
7580     char path[] = "/new";
7581     int r;
7582     suppress_error = 0;
7583     r = guestfs_mkdir (g, path);
7584     if (r == -1)
7585       return -1;
7586   }
7587   {
7588     char path[] = "/new";
7589     int r;
7590     suppress_error = 0;
7591     r = guestfs_is_dir (g, path);
7592     if (r == -1)
7593       return -1;
7594     if (!r) {
7595       fprintf (stderr, "test_mkdir_0: expected true, got false\n");
7596       return -1;
7597     }
7598   }
7599   return 0;
7600 }
7601
7602 static int test_mkdir_1 (void)
7603 {
7604   /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
7605   {
7606     char device[] = "/dev/sda";
7607     device[5] = devchar;
7608     int r;
7609     suppress_error = 0;
7610     r = guestfs_blockdev_setrw (g, device);
7611     if (r == -1)
7612       return -1;
7613   }
7614   {
7615     int r;
7616     suppress_error = 0;
7617     r = guestfs_umount_all (g);
7618     if (r == -1)
7619       return -1;
7620   }
7621   {
7622     int r;
7623     suppress_error = 0;
7624     r = guestfs_lvm_remove_all (g);
7625     if (r == -1)
7626       return -1;
7627   }
7628   {
7629     char device[] = "/dev/sda";
7630     device[5] = devchar;
7631     char lines_0[] = ",";
7632     char *lines[] = {
7633       lines_0,
7634       NULL
7635     };
7636     int r;
7637     suppress_error = 0;
7638     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7639     if (r == -1)
7640       return -1;
7641   }
7642   {
7643     char fstype[] = "ext2";
7644     char device[] = "/dev/sda1";
7645     device[5] = devchar;
7646     int r;
7647     suppress_error = 0;
7648     r = guestfs_mkfs (g, fstype, device);
7649     if (r == -1)
7650       return -1;
7651   }
7652   {
7653     char device[] = "/dev/sda1";
7654     device[5] = devchar;
7655     char mountpoint[] = "/";
7656     int r;
7657     suppress_error = 0;
7658     r = guestfs_mount (g, device, mountpoint);
7659     if (r == -1)
7660       return -1;
7661   }
7662   /* TestLastFail for mkdir (1) */
7663   {
7664     char path[] = "/new/foo/bar";
7665     int r;
7666     suppress_error = 1;
7667     r = guestfs_mkdir (g, path);
7668     if (r != -1)
7669       return -1;
7670   }
7671   return 0;
7672 }
7673
7674 static int test_rm_rf_0 (void)
7675 {
7676   /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
7677   {
7678     char device[] = "/dev/sda";
7679     device[5] = devchar;
7680     int r;
7681     suppress_error = 0;
7682     r = guestfs_blockdev_setrw (g, device);
7683     if (r == -1)
7684       return -1;
7685   }
7686   {
7687     int r;
7688     suppress_error = 0;
7689     r = guestfs_umount_all (g);
7690     if (r == -1)
7691       return -1;
7692   }
7693   {
7694     int r;
7695     suppress_error = 0;
7696     r = guestfs_lvm_remove_all (g);
7697     if (r == -1)
7698       return -1;
7699   }
7700   {
7701     char device[] = "/dev/sda";
7702     device[5] = devchar;
7703     char lines_0[] = ",";
7704     char *lines[] = {
7705       lines_0,
7706       NULL
7707     };
7708     int r;
7709     suppress_error = 0;
7710     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7711     if (r == -1)
7712       return -1;
7713   }
7714   {
7715     char fstype[] = "ext2";
7716     char device[] = "/dev/sda1";
7717     device[5] = devchar;
7718     int r;
7719     suppress_error = 0;
7720     r = guestfs_mkfs (g, fstype, device);
7721     if (r == -1)
7722       return -1;
7723   }
7724   {
7725     char device[] = "/dev/sda1";
7726     device[5] = devchar;
7727     char mountpoint[] = "/";
7728     int r;
7729     suppress_error = 0;
7730     r = guestfs_mount (g, device, mountpoint);
7731     if (r == -1)
7732       return -1;
7733   }
7734   /* TestOutputFalse for rm_rf (0) */
7735   {
7736     char path[] = "/new";
7737     int r;
7738     suppress_error = 0;
7739     r = guestfs_mkdir (g, path);
7740     if (r == -1)
7741       return -1;
7742   }
7743   {
7744     char path[] = "/new/foo";
7745     int r;
7746     suppress_error = 0;
7747     r = guestfs_mkdir (g, path);
7748     if (r == -1)
7749       return -1;
7750   }
7751   {
7752     char path[] = "/new/foo/bar";
7753     int r;
7754     suppress_error = 0;
7755     r = guestfs_touch (g, path);
7756     if (r == -1)
7757       return -1;
7758   }
7759   {
7760     char path[] = "/new";
7761     int r;
7762     suppress_error = 0;
7763     r = guestfs_rm_rf (g, path);
7764     if (r == -1)
7765       return -1;
7766   }
7767   {
7768     char path[] = "/new";
7769     int r;
7770     suppress_error = 0;
7771     r = guestfs_exists (g, path);
7772     if (r == -1)
7773       return -1;
7774     if (r) {
7775       fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
7776       return -1;
7777     }
7778   }
7779   return 0;
7780 }
7781
7782 static int test_rmdir_0 (void)
7783 {
7784   /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
7785   {
7786     char device[] = "/dev/sda";
7787     device[5] = devchar;
7788     int r;
7789     suppress_error = 0;
7790     r = guestfs_blockdev_setrw (g, device);
7791     if (r == -1)
7792       return -1;
7793   }
7794   {
7795     int r;
7796     suppress_error = 0;
7797     r = guestfs_umount_all (g);
7798     if (r == -1)
7799       return -1;
7800   }
7801   {
7802     int r;
7803     suppress_error = 0;
7804     r = guestfs_lvm_remove_all (g);
7805     if (r == -1)
7806       return -1;
7807   }
7808   {
7809     char device[] = "/dev/sda";
7810     device[5] = devchar;
7811     char lines_0[] = ",";
7812     char *lines[] = {
7813       lines_0,
7814       NULL
7815     };
7816     int r;
7817     suppress_error = 0;
7818     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7819     if (r == -1)
7820       return -1;
7821   }
7822   {
7823     char fstype[] = "ext2";
7824     char device[] = "/dev/sda1";
7825     device[5] = devchar;
7826     int r;
7827     suppress_error = 0;
7828     r = guestfs_mkfs (g, fstype, device);
7829     if (r == -1)
7830       return -1;
7831   }
7832   {
7833     char device[] = "/dev/sda1";
7834     device[5] = devchar;
7835     char mountpoint[] = "/";
7836     int r;
7837     suppress_error = 0;
7838     r = guestfs_mount (g, device, mountpoint);
7839     if (r == -1)
7840       return -1;
7841   }
7842   /* TestRun for rmdir (0) */
7843   {
7844     char path[] = "/new";
7845     int r;
7846     suppress_error = 0;
7847     r = guestfs_mkdir (g, path);
7848     if (r == -1)
7849       return -1;
7850   }
7851   {
7852     char path[] = "/new";
7853     int r;
7854     suppress_error = 0;
7855     r = guestfs_rmdir (g, path);
7856     if (r == -1)
7857       return -1;
7858   }
7859   return 0;
7860 }
7861
7862 static int test_rmdir_1 (void)
7863 {
7864   /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
7865   {
7866     char device[] = "/dev/sda";
7867     device[5] = devchar;
7868     int r;
7869     suppress_error = 0;
7870     r = guestfs_blockdev_setrw (g, device);
7871     if (r == -1)
7872       return -1;
7873   }
7874   {
7875     int r;
7876     suppress_error = 0;
7877     r = guestfs_umount_all (g);
7878     if (r == -1)
7879       return -1;
7880   }
7881   {
7882     int r;
7883     suppress_error = 0;
7884     r = guestfs_lvm_remove_all (g);
7885     if (r == -1)
7886       return -1;
7887   }
7888   {
7889     char device[] = "/dev/sda";
7890     device[5] = devchar;
7891     char lines_0[] = ",";
7892     char *lines[] = {
7893       lines_0,
7894       NULL
7895     };
7896     int r;
7897     suppress_error = 0;
7898     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7899     if (r == -1)
7900       return -1;
7901   }
7902   {
7903     char fstype[] = "ext2";
7904     char device[] = "/dev/sda1";
7905     device[5] = devchar;
7906     int r;
7907     suppress_error = 0;
7908     r = guestfs_mkfs (g, fstype, device);
7909     if (r == -1)
7910       return -1;
7911   }
7912   {
7913     char device[] = "/dev/sda1";
7914     device[5] = devchar;
7915     char mountpoint[] = "/";
7916     int r;
7917     suppress_error = 0;
7918     r = guestfs_mount (g, device, mountpoint);
7919     if (r == -1)
7920       return -1;
7921   }
7922   /* TestLastFail for rmdir (1) */
7923   {
7924     char path[] = "/new";
7925     int r;
7926     suppress_error = 1;
7927     r = guestfs_rmdir (g, path);
7928     if (r != -1)
7929       return -1;
7930   }
7931   return 0;
7932 }
7933
7934 static int test_rmdir_2 (void)
7935 {
7936   /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
7937   {
7938     char device[] = "/dev/sda";
7939     device[5] = devchar;
7940     int r;
7941     suppress_error = 0;
7942     r = guestfs_blockdev_setrw (g, device);
7943     if (r == -1)
7944       return -1;
7945   }
7946   {
7947     int r;
7948     suppress_error = 0;
7949     r = guestfs_umount_all (g);
7950     if (r == -1)
7951       return -1;
7952   }
7953   {
7954     int r;
7955     suppress_error = 0;
7956     r = guestfs_lvm_remove_all (g);
7957     if (r == -1)
7958       return -1;
7959   }
7960   {
7961     char device[] = "/dev/sda";
7962     device[5] = devchar;
7963     char lines_0[] = ",";
7964     char *lines[] = {
7965       lines_0,
7966       NULL
7967     };
7968     int r;
7969     suppress_error = 0;
7970     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7971     if (r == -1)
7972       return -1;
7973   }
7974   {
7975     char fstype[] = "ext2";
7976     char device[] = "/dev/sda1";
7977     device[5] = devchar;
7978     int r;
7979     suppress_error = 0;
7980     r = guestfs_mkfs (g, fstype, device);
7981     if (r == -1)
7982       return -1;
7983   }
7984   {
7985     char device[] = "/dev/sda1";
7986     device[5] = devchar;
7987     char mountpoint[] = "/";
7988     int r;
7989     suppress_error = 0;
7990     r = guestfs_mount (g, device, mountpoint);
7991     if (r == -1)
7992       return -1;
7993   }
7994   /* TestLastFail for rmdir (2) */
7995   {
7996     char path[] = "/new";
7997     int r;
7998     suppress_error = 0;
7999     r = guestfs_touch (g, path);
8000     if (r == -1)
8001       return -1;
8002   }
8003   {
8004     char path[] = "/new";
8005     int r;
8006     suppress_error = 1;
8007     r = guestfs_rmdir (g, path);
8008     if (r != -1)
8009       return -1;
8010   }
8011   return 0;
8012 }
8013
8014 static int test_rm_0 (void)
8015 {
8016   /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
8017   {
8018     char device[] = "/dev/sda";
8019     device[5] = devchar;
8020     int r;
8021     suppress_error = 0;
8022     r = guestfs_blockdev_setrw (g, device);
8023     if (r == -1)
8024       return -1;
8025   }
8026   {
8027     int r;
8028     suppress_error = 0;
8029     r = guestfs_umount_all (g);
8030     if (r == -1)
8031       return -1;
8032   }
8033   {
8034     int r;
8035     suppress_error = 0;
8036     r = guestfs_lvm_remove_all (g);
8037     if (r == -1)
8038       return -1;
8039   }
8040   {
8041     char device[] = "/dev/sda";
8042     device[5] = devchar;
8043     char lines_0[] = ",";
8044     char *lines[] = {
8045       lines_0,
8046       NULL
8047     };
8048     int r;
8049     suppress_error = 0;
8050     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8051     if (r == -1)
8052       return -1;
8053   }
8054   {
8055     char fstype[] = "ext2";
8056     char device[] = "/dev/sda1";
8057     device[5] = devchar;
8058     int r;
8059     suppress_error = 0;
8060     r = guestfs_mkfs (g, fstype, device);
8061     if (r == -1)
8062       return -1;
8063   }
8064   {
8065     char device[] = "/dev/sda1";
8066     device[5] = devchar;
8067     char mountpoint[] = "/";
8068     int r;
8069     suppress_error = 0;
8070     r = guestfs_mount (g, device, mountpoint);
8071     if (r == -1)
8072       return -1;
8073   }
8074   /* TestRun for rm (0) */
8075   {
8076     char path[] = "/new";
8077     int r;
8078     suppress_error = 0;
8079     r = guestfs_touch (g, path);
8080     if (r == -1)
8081       return -1;
8082   }
8083   {
8084     char path[] = "/new";
8085     int r;
8086     suppress_error = 0;
8087     r = guestfs_rm (g, path);
8088     if (r == -1)
8089       return -1;
8090   }
8091   return 0;
8092 }
8093
8094 static int test_rm_1 (void)
8095 {
8096   /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
8097   {
8098     char device[] = "/dev/sda";
8099     device[5] = devchar;
8100     int r;
8101     suppress_error = 0;
8102     r = guestfs_blockdev_setrw (g, device);
8103     if (r == -1)
8104       return -1;
8105   }
8106   {
8107     int r;
8108     suppress_error = 0;
8109     r = guestfs_umount_all (g);
8110     if (r == -1)
8111       return -1;
8112   }
8113   {
8114     int r;
8115     suppress_error = 0;
8116     r = guestfs_lvm_remove_all (g);
8117     if (r == -1)
8118       return -1;
8119   }
8120   {
8121     char device[] = "/dev/sda";
8122     device[5] = devchar;
8123     char lines_0[] = ",";
8124     char *lines[] = {
8125       lines_0,
8126       NULL
8127     };
8128     int r;
8129     suppress_error = 0;
8130     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8131     if (r == -1)
8132       return -1;
8133   }
8134   {
8135     char fstype[] = "ext2";
8136     char device[] = "/dev/sda1";
8137     device[5] = devchar;
8138     int r;
8139     suppress_error = 0;
8140     r = guestfs_mkfs (g, fstype, device);
8141     if (r == -1)
8142       return -1;
8143   }
8144   {
8145     char device[] = "/dev/sda1";
8146     device[5] = devchar;
8147     char mountpoint[] = "/";
8148     int r;
8149     suppress_error = 0;
8150     r = guestfs_mount (g, device, mountpoint);
8151     if (r == -1)
8152       return -1;
8153   }
8154   /* TestLastFail for rm (1) */
8155   {
8156     char path[] = "/new";
8157     int r;
8158     suppress_error = 1;
8159     r = guestfs_rm (g, path);
8160     if (r != -1)
8161       return -1;
8162   }
8163   return 0;
8164 }
8165
8166 static int test_rm_2 (void)
8167 {
8168   /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
8169   {
8170     char device[] = "/dev/sda";
8171     device[5] = devchar;
8172     int r;
8173     suppress_error = 0;
8174     r = guestfs_blockdev_setrw (g, device);
8175     if (r == -1)
8176       return -1;
8177   }
8178   {
8179     int r;
8180     suppress_error = 0;
8181     r = guestfs_umount_all (g);
8182     if (r == -1)
8183       return -1;
8184   }
8185   {
8186     int r;
8187     suppress_error = 0;
8188     r = guestfs_lvm_remove_all (g);
8189     if (r == -1)
8190       return -1;
8191   }
8192   {
8193     char device[] = "/dev/sda";
8194     device[5] = devchar;
8195     char lines_0[] = ",";
8196     char *lines[] = {
8197       lines_0,
8198       NULL
8199     };
8200     int r;
8201     suppress_error = 0;
8202     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8203     if (r == -1)
8204       return -1;
8205   }
8206   {
8207     char fstype[] = "ext2";
8208     char device[] = "/dev/sda1";
8209     device[5] = devchar;
8210     int r;
8211     suppress_error = 0;
8212     r = guestfs_mkfs (g, fstype, device);
8213     if (r == -1)
8214       return -1;
8215   }
8216   {
8217     char device[] = "/dev/sda1";
8218     device[5] = devchar;
8219     char mountpoint[] = "/";
8220     int r;
8221     suppress_error = 0;
8222     r = guestfs_mount (g, device, mountpoint);
8223     if (r == -1)
8224       return -1;
8225   }
8226   /* TestLastFail for rm (2) */
8227   {
8228     char path[] = "/new";
8229     int r;
8230     suppress_error = 0;
8231     r = guestfs_mkdir (g, path);
8232     if (r == -1)
8233       return -1;
8234   }
8235   {
8236     char path[] = "/new";
8237     int r;
8238     suppress_error = 1;
8239     r = guestfs_rm (g, path);
8240     if (r != -1)
8241       return -1;
8242   }
8243   return 0;
8244 }
8245
8246 static int test_read_lines_0 (void)
8247 {
8248   /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
8249   {
8250     char device[] = "/dev/sda";
8251     device[5] = devchar;
8252     int r;
8253     suppress_error = 0;
8254     r = guestfs_blockdev_setrw (g, device);
8255     if (r == -1)
8256       return -1;
8257   }
8258   {
8259     int r;
8260     suppress_error = 0;
8261     r = guestfs_umount_all (g);
8262     if (r == -1)
8263       return -1;
8264   }
8265   {
8266     int r;
8267     suppress_error = 0;
8268     r = guestfs_lvm_remove_all (g);
8269     if (r == -1)
8270       return -1;
8271   }
8272   {
8273     char device[] = "/dev/sda";
8274     device[5] = devchar;
8275     char lines_0[] = ",";
8276     char *lines[] = {
8277       lines_0,
8278       NULL
8279     };
8280     int r;
8281     suppress_error = 0;
8282     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8283     if (r == -1)
8284       return -1;
8285   }
8286   {
8287     char fstype[] = "ext2";
8288     char device[] = "/dev/sda1";
8289     device[5] = devchar;
8290     int r;
8291     suppress_error = 0;
8292     r = guestfs_mkfs (g, fstype, device);
8293     if (r == -1)
8294       return -1;
8295   }
8296   {
8297     char device[] = "/dev/sda1";
8298     device[5] = devchar;
8299     char mountpoint[] = "/";
8300     int r;
8301     suppress_error = 0;
8302     r = guestfs_mount (g, device, mountpoint);
8303     if (r == -1)
8304       return -1;
8305   }
8306   /* TestOutputList for read_lines (0) */
8307   {
8308     char path[] = "/new";
8309     char content[] = "line1\r\nline2\nline3";
8310     int r;
8311     suppress_error = 0;
8312     r = guestfs_write_file (g, path, content, 0);
8313     if (r == -1)
8314       return -1;
8315   }
8316   {
8317     char path[] = "/new";
8318     char **r;
8319     int i;
8320     suppress_error = 0;
8321     r = guestfs_read_lines (g, path);
8322     if (r == NULL)
8323       return -1;
8324     if (!r[0]) {
8325       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8326       print_strings (r);
8327       return -1;
8328     }
8329     {
8330       char expected[] = "line1";
8331       if (strcmp (r[0], expected) != 0) {
8332         fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8333         return -1;
8334       }
8335     }
8336     if (!r[1]) {
8337       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8338       print_strings (r);
8339       return -1;
8340     }
8341     {
8342       char expected[] = "line2";
8343       if (strcmp (r[1], expected) != 0) {
8344         fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8345         return -1;
8346       }
8347     }
8348     if (!r[2]) {
8349       fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8350       print_strings (r);
8351       return -1;
8352     }
8353     {
8354       char expected[] = "line3";
8355       if (strcmp (r[2], expected) != 0) {
8356         fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8357         return -1;
8358       }
8359     }
8360     if (r[3] != NULL) {
8361       fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
8362       print_strings (r);
8363       return -1;
8364     }
8365     for (i = 0; r[i] != NULL; ++i)
8366       free (r[i]);
8367     free (r);
8368   }
8369   return 0;
8370 }
8371
8372 static int test_read_lines_1 (void)
8373 {
8374   /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
8375   {
8376     char device[] = "/dev/sda";
8377     device[5] = devchar;
8378     int r;
8379     suppress_error = 0;
8380     r = guestfs_blockdev_setrw (g, device);
8381     if (r == -1)
8382       return -1;
8383   }
8384   {
8385     int r;
8386     suppress_error = 0;
8387     r = guestfs_umount_all (g);
8388     if (r == -1)
8389       return -1;
8390   }
8391   {
8392     int r;
8393     suppress_error = 0;
8394     r = guestfs_lvm_remove_all (g);
8395     if (r == -1)
8396       return -1;
8397   }
8398   {
8399     char device[] = "/dev/sda";
8400     device[5] = devchar;
8401     char lines_0[] = ",";
8402     char *lines[] = {
8403       lines_0,
8404       NULL
8405     };
8406     int r;
8407     suppress_error = 0;
8408     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8409     if (r == -1)
8410       return -1;
8411   }
8412   {
8413     char fstype[] = "ext2";
8414     char device[] = "/dev/sda1";
8415     device[5] = devchar;
8416     int r;
8417     suppress_error = 0;
8418     r = guestfs_mkfs (g, fstype, device);
8419     if (r == -1)
8420       return -1;
8421   }
8422   {
8423     char device[] = "/dev/sda1";
8424     device[5] = devchar;
8425     char mountpoint[] = "/";
8426     int r;
8427     suppress_error = 0;
8428     r = guestfs_mount (g, device, mountpoint);
8429     if (r == -1)
8430       return -1;
8431   }
8432   /* TestOutputList for read_lines (1) */
8433   {
8434     char path[] = "/new";
8435     char content[] = "";
8436     int r;
8437     suppress_error = 0;
8438     r = guestfs_write_file (g, path, content, 0);
8439     if (r == -1)
8440       return -1;
8441   }
8442   {
8443     char path[] = "/new";
8444     char **r;
8445     int i;
8446     suppress_error = 0;
8447     r = guestfs_read_lines (g, path);
8448     if (r == NULL)
8449       return -1;
8450     if (r[0] != NULL) {
8451       fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
8452       print_strings (r);
8453       return -1;
8454     }
8455     for (i = 0; r[i] != NULL; ++i)
8456       free (r[i]);
8457     free (r);
8458   }
8459   return 0;
8460 }
8461
8462 static int test_lvs_0 (void)
8463 {
8464   /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
8465   {
8466     char device[] = "/dev/sda";
8467     device[5] = devchar;
8468     int r;
8469     suppress_error = 0;
8470     r = guestfs_blockdev_setrw (g, device);
8471     if (r == -1)
8472       return -1;
8473   }
8474   {
8475     int r;
8476     suppress_error = 0;
8477     r = guestfs_umount_all (g);
8478     if (r == -1)
8479       return -1;
8480   }
8481   {
8482     int r;
8483     suppress_error = 0;
8484     r = guestfs_lvm_remove_all (g);
8485     if (r == -1)
8486       return -1;
8487   }
8488   {
8489     char device[] = "/dev/sda";
8490     device[5] = devchar;
8491     char lines_0[] = ",";
8492     char *lines[] = {
8493       lines_0,
8494       NULL
8495     };
8496     int r;
8497     suppress_error = 0;
8498     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8499     if (r == -1)
8500       return -1;
8501   }
8502   {
8503     char device[] = "/dev/sda1";
8504     device[5] = devchar;
8505     int r;
8506     suppress_error = 0;
8507     r = guestfs_pvcreate (g, device);
8508     if (r == -1)
8509       return -1;
8510   }
8511   {
8512     char volgroup[] = "VG";
8513     char physvols_0[] = "/dev/sda1";
8514     physvols_0[5] = devchar;
8515     char *physvols[] = {
8516       physvols_0,
8517       NULL
8518     };
8519     int r;
8520     suppress_error = 0;
8521     r = guestfs_vgcreate (g, volgroup, physvols);
8522     if (r == -1)
8523       return -1;
8524   }
8525   {
8526     char logvol[] = "LV";
8527     char volgroup[] = "VG";
8528     int r;
8529     suppress_error = 0;
8530     r = guestfs_lvcreate (g, logvol, volgroup, 8);
8531     if (r == -1)
8532       return -1;
8533   }
8534   {
8535     char fstype[] = "ext2";
8536     char device[] = "/dev/VG/LV";
8537     int r;
8538     suppress_error = 0;
8539     r = guestfs_mkfs (g, fstype, device);
8540     if (r == -1)
8541       return -1;
8542   }
8543   {
8544     char device[] = "/dev/VG/LV";
8545     char mountpoint[] = "/";
8546     int r;
8547     suppress_error = 0;
8548     r = guestfs_mount (g, device, mountpoint);
8549     if (r == -1)
8550       return -1;
8551   }
8552   /* TestOutputList for lvs (0) */
8553   {
8554     char **r;
8555     int i;
8556     suppress_error = 0;
8557     r = guestfs_lvs (g);
8558     if (r == NULL)
8559       return -1;
8560     if (!r[0]) {
8561       fprintf (stderr, "test_lvs_0: short list returned from command\n");
8562       print_strings (r);
8563       return -1;
8564     }
8565     {
8566       char expected[] = "/dev/VG/LV";
8567       if (strcmp (r[0], expected) != 0) {
8568         fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8569         return -1;
8570       }
8571     }
8572     if (r[1] != NULL) {
8573       fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
8574       print_strings (r);
8575       return -1;
8576     }
8577     for (i = 0; r[i] != NULL; ++i)
8578       free (r[i]);
8579     free (r);
8580   }
8581   return 0;
8582 }
8583
8584 static int test_lvs_1 (void)
8585 {
8586   /* InitEmpty for lvs (1) */
8587   {
8588     char device[] = "/dev/sda";
8589     device[5] = devchar;
8590     int r;
8591     suppress_error = 0;
8592     r = guestfs_blockdev_setrw (g, device);
8593     if (r == -1)
8594       return -1;
8595   }
8596   {
8597     int r;
8598     suppress_error = 0;
8599     r = guestfs_umount_all (g);
8600     if (r == -1)
8601       return -1;
8602   }
8603   {
8604     int r;
8605     suppress_error = 0;
8606     r = guestfs_lvm_remove_all (g);
8607     if (r == -1)
8608       return -1;
8609   }
8610   /* TestOutputList for lvs (1) */
8611   {
8612     char device[] = "/dev/sda";
8613     device[5] = devchar;
8614     char lines_0[] = ",10";
8615     char lines_1[] = ",20";
8616     char lines_2[] = ",";
8617     char *lines[] = {
8618       lines_0,
8619       lines_1,
8620       lines_2,
8621       NULL
8622     };
8623     int r;
8624     suppress_error = 0;
8625     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8626     if (r == -1)
8627       return -1;
8628   }
8629   {
8630     char device[] = "/dev/sda1";
8631     device[5] = devchar;
8632     int r;
8633     suppress_error = 0;
8634     r = guestfs_pvcreate (g, device);
8635     if (r == -1)
8636       return -1;
8637   }
8638   {
8639     char device[] = "/dev/sda2";
8640     device[5] = devchar;
8641     int r;
8642     suppress_error = 0;
8643     r = guestfs_pvcreate (g, device);
8644     if (r == -1)
8645       return -1;
8646   }
8647   {
8648     char device[] = "/dev/sda3";
8649     device[5] = devchar;
8650     int r;
8651     suppress_error = 0;
8652     r = guestfs_pvcreate (g, device);
8653     if (r == -1)
8654       return -1;
8655   }
8656   {
8657     char volgroup[] = "VG1";
8658     char physvols_0[] = "/dev/sda1";
8659     physvols_0[5] = devchar;
8660     char physvols_1[] = "/dev/sda2";
8661     physvols_1[5] = devchar;
8662     char *physvols[] = {
8663       physvols_0,
8664       physvols_1,
8665       NULL
8666     };
8667     int r;
8668     suppress_error = 0;
8669     r = guestfs_vgcreate (g, volgroup, physvols);
8670     if (r == -1)
8671       return -1;
8672   }
8673   {
8674     char volgroup[] = "VG2";
8675     char physvols_0[] = "/dev/sda3";
8676     physvols_0[5] = devchar;
8677     char *physvols[] = {
8678       physvols_0,
8679       NULL
8680     };
8681     int r;
8682     suppress_error = 0;
8683     r = guestfs_vgcreate (g, volgroup, physvols);
8684     if (r == -1)
8685       return -1;
8686   }
8687   {
8688     char logvol[] = "LV1";
8689     char volgroup[] = "VG1";
8690     int r;
8691     suppress_error = 0;
8692     r = guestfs_lvcreate (g, logvol, volgroup, 50);
8693     if (r == -1)
8694       return -1;
8695   }
8696   {
8697     char logvol[] = "LV2";
8698     char volgroup[] = "VG1";
8699     int r;
8700     suppress_error = 0;
8701     r = guestfs_lvcreate (g, logvol, volgroup, 50);
8702     if (r == -1)
8703       return -1;
8704   }
8705   {
8706     char logvol[] = "LV3";
8707     char volgroup[] = "VG2";
8708     int r;
8709     suppress_error = 0;
8710     r = guestfs_lvcreate (g, logvol, volgroup, 50);
8711     if (r == -1)
8712       return -1;
8713   }
8714   {
8715     char **r;
8716     int i;
8717     suppress_error = 0;
8718     r = guestfs_lvs (g);
8719     if (r == NULL)
8720       return -1;
8721     if (!r[0]) {
8722       fprintf (stderr, "test_lvs_1: short list returned from command\n");
8723       print_strings (r);
8724       return -1;
8725     }
8726     {
8727       char expected[] = "/dev/VG1/LV1";
8728       if (strcmp (r[0], expected) != 0) {
8729         fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8730         return -1;
8731       }
8732     }
8733     if (!r[1]) {
8734       fprintf (stderr, "test_lvs_1: short list returned from command\n");
8735       print_strings (r);
8736       return -1;
8737     }
8738     {
8739       char expected[] = "/dev/VG1/LV2";
8740       if (strcmp (r[1], expected) != 0) {
8741         fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8742         return -1;
8743       }
8744     }
8745     if (!r[2]) {
8746       fprintf (stderr, "test_lvs_1: short list returned from command\n");
8747       print_strings (r);
8748       return -1;
8749     }
8750     {
8751       char expected[] = "/dev/VG2/LV3";
8752       if (strcmp (r[2], expected) != 0) {
8753         fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8754         return -1;
8755       }
8756     }
8757     if (r[3] != NULL) {
8758       fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
8759       print_strings (r);
8760       return -1;
8761     }
8762     for (i = 0; r[i] != NULL; ++i)
8763       free (r[i]);
8764     free (r);
8765   }
8766   return 0;
8767 }
8768
8769 static int test_vgs_0 (void)
8770 {
8771   /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
8772   {
8773     char device[] = "/dev/sda";
8774     device[5] = devchar;
8775     int r;
8776     suppress_error = 0;
8777     r = guestfs_blockdev_setrw (g, device);
8778     if (r == -1)
8779       return -1;
8780   }
8781   {
8782     int r;
8783     suppress_error = 0;
8784     r = guestfs_umount_all (g);
8785     if (r == -1)
8786       return -1;
8787   }
8788   {
8789     int r;
8790     suppress_error = 0;
8791     r = guestfs_lvm_remove_all (g);
8792     if (r == -1)
8793       return -1;
8794   }
8795   {
8796     char device[] = "/dev/sda";
8797     device[5] = devchar;
8798     char lines_0[] = ",";
8799     char *lines[] = {
8800       lines_0,
8801       NULL
8802     };
8803     int r;
8804     suppress_error = 0;
8805     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8806     if (r == -1)
8807       return -1;
8808   }
8809   {
8810     char device[] = "/dev/sda1";
8811     device[5] = devchar;
8812     int r;
8813     suppress_error = 0;
8814     r = guestfs_pvcreate (g, device);
8815     if (r == -1)
8816       return -1;
8817   }
8818   {
8819     char volgroup[] = "VG";
8820     char physvols_0[] = "/dev/sda1";
8821     physvols_0[5] = devchar;
8822     char *physvols[] = {
8823       physvols_0,
8824       NULL
8825     };
8826     int r;
8827     suppress_error = 0;
8828     r = guestfs_vgcreate (g, volgroup, physvols);
8829     if (r == -1)
8830       return -1;
8831   }
8832   {
8833     char logvol[] = "LV";
8834     char volgroup[] = "VG";
8835     int r;
8836     suppress_error = 0;
8837     r = guestfs_lvcreate (g, logvol, volgroup, 8);
8838     if (r == -1)
8839       return -1;
8840   }
8841   {
8842     char fstype[] = "ext2";
8843     char device[] = "/dev/VG/LV";
8844     int r;
8845     suppress_error = 0;
8846     r = guestfs_mkfs (g, fstype, device);
8847     if (r == -1)
8848       return -1;
8849   }
8850   {
8851     char device[] = "/dev/VG/LV";
8852     char mountpoint[] = "/";
8853     int r;
8854     suppress_error = 0;
8855     r = guestfs_mount (g, device, mountpoint);
8856     if (r == -1)
8857       return -1;
8858   }
8859   /* TestOutputList for vgs (0) */
8860   {
8861     char **r;
8862     int i;
8863     suppress_error = 0;
8864     r = guestfs_vgs (g);
8865     if (r == NULL)
8866       return -1;
8867     if (!r[0]) {
8868       fprintf (stderr, "test_vgs_0: short list returned from command\n");
8869       print_strings (r);
8870       return -1;
8871     }
8872     {
8873       char expected[] = "VG";
8874       if (strcmp (r[0], expected) != 0) {
8875         fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8876         return -1;
8877       }
8878     }
8879     if (r[1] != NULL) {
8880       fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
8881       print_strings (r);
8882       return -1;
8883     }
8884     for (i = 0; r[i] != NULL; ++i)
8885       free (r[i]);
8886     free (r);
8887   }
8888   return 0;
8889 }
8890
8891 static int test_vgs_1 (void)
8892 {
8893   /* InitEmpty for vgs (1) */
8894   {
8895     char device[] = "/dev/sda";
8896     device[5] = devchar;
8897     int r;
8898     suppress_error = 0;
8899     r = guestfs_blockdev_setrw (g, device);
8900     if (r == -1)
8901       return -1;
8902   }
8903   {
8904     int r;
8905     suppress_error = 0;
8906     r = guestfs_umount_all (g);
8907     if (r == -1)
8908       return -1;
8909   }
8910   {
8911     int r;
8912     suppress_error = 0;
8913     r = guestfs_lvm_remove_all (g);
8914     if (r == -1)
8915       return -1;
8916   }
8917   /* TestOutputList for vgs (1) */
8918   {
8919     char device[] = "/dev/sda";
8920     device[5] = devchar;
8921     char lines_0[] = ",10";
8922     char lines_1[] = ",20";
8923     char lines_2[] = ",";
8924     char *lines[] = {
8925       lines_0,
8926       lines_1,
8927       lines_2,
8928       NULL
8929     };
8930     int r;
8931     suppress_error = 0;
8932     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8933     if (r == -1)
8934       return -1;
8935   }
8936   {
8937     char device[] = "/dev/sda1";
8938     device[5] = devchar;
8939     int r;
8940     suppress_error = 0;
8941     r = guestfs_pvcreate (g, device);
8942     if (r == -1)
8943       return -1;
8944   }
8945   {
8946     char device[] = "/dev/sda2";
8947     device[5] = devchar;
8948     int r;
8949     suppress_error = 0;
8950     r = guestfs_pvcreate (g, device);
8951     if (r == -1)
8952       return -1;
8953   }
8954   {
8955     char device[] = "/dev/sda3";
8956     device[5] = devchar;
8957     int r;
8958     suppress_error = 0;
8959     r = guestfs_pvcreate (g, device);
8960     if (r == -1)
8961       return -1;
8962   }
8963   {
8964     char volgroup[] = "VG1";
8965     char physvols_0[] = "/dev/sda1";
8966     physvols_0[5] = devchar;
8967     char physvols_1[] = "/dev/sda2";
8968     physvols_1[5] = devchar;
8969     char *physvols[] = {
8970       physvols_0,
8971       physvols_1,
8972       NULL
8973     };
8974     int r;
8975     suppress_error = 0;
8976     r = guestfs_vgcreate (g, volgroup, physvols);
8977     if (r == -1)
8978       return -1;
8979   }
8980   {
8981     char volgroup[] = "VG2";
8982     char physvols_0[] = "/dev/sda3";
8983     physvols_0[5] = devchar;
8984     char *physvols[] = {
8985       physvols_0,
8986       NULL
8987     };
8988     int r;
8989     suppress_error = 0;
8990     r = guestfs_vgcreate (g, volgroup, physvols);
8991     if (r == -1)
8992       return -1;
8993   }
8994   {
8995     char **r;
8996     int i;
8997     suppress_error = 0;
8998     r = guestfs_vgs (g);
8999     if (r == NULL)
9000       return -1;
9001     if (!r[0]) {
9002       fprintf (stderr, "test_vgs_1: short list returned from command\n");
9003       print_strings (r);
9004       return -1;
9005     }
9006     {
9007       char expected[] = "VG1";
9008       if (strcmp (r[0], expected) != 0) {
9009         fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9010         return -1;
9011       }
9012     }
9013     if (!r[1]) {
9014       fprintf (stderr, "test_vgs_1: short list returned from command\n");
9015       print_strings (r);
9016       return -1;
9017     }
9018     {
9019       char expected[] = "VG2";
9020       if (strcmp (r[1], expected) != 0) {
9021         fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9022         return -1;
9023       }
9024     }
9025     if (r[2] != NULL) {
9026       fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
9027       print_strings (r);
9028       return -1;
9029     }
9030     for (i = 0; r[i] != NULL; ++i)
9031       free (r[i]);
9032     free (r);
9033   }
9034   return 0;
9035 }
9036
9037 static int test_pvs_0 (void)
9038 {
9039   /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
9040   {
9041     char device[] = "/dev/sda";
9042     device[5] = devchar;
9043     int r;
9044     suppress_error = 0;
9045     r = guestfs_blockdev_setrw (g, device);
9046     if (r == -1)
9047       return -1;
9048   }
9049   {
9050     int r;
9051     suppress_error = 0;
9052     r = guestfs_umount_all (g);
9053     if (r == -1)
9054       return -1;
9055   }
9056   {
9057     int r;
9058     suppress_error = 0;
9059     r = guestfs_lvm_remove_all (g);
9060     if (r == -1)
9061       return -1;
9062   }
9063   {
9064     char device[] = "/dev/sda";
9065     device[5] = devchar;
9066     char lines_0[] = ",";
9067     char *lines[] = {
9068       lines_0,
9069       NULL
9070     };
9071     int r;
9072     suppress_error = 0;
9073     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9074     if (r == -1)
9075       return -1;
9076   }
9077   {
9078     char device[] = "/dev/sda1";
9079     device[5] = devchar;
9080     int r;
9081     suppress_error = 0;
9082     r = guestfs_pvcreate (g, device);
9083     if (r == -1)
9084       return -1;
9085   }
9086   {
9087     char volgroup[] = "VG";
9088     char physvols_0[] = "/dev/sda1";
9089     physvols_0[5] = devchar;
9090     char *physvols[] = {
9091       physvols_0,
9092       NULL
9093     };
9094     int r;
9095     suppress_error = 0;
9096     r = guestfs_vgcreate (g, volgroup, physvols);
9097     if (r == -1)
9098       return -1;
9099   }
9100   {
9101     char logvol[] = "LV";
9102     char volgroup[] = "VG";
9103     int r;
9104     suppress_error = 0;
9105     r = guestfs_lvcreate (g, logvol, volgroup, 8);
9106     if (r == -1)
9107       return -1;
9108   }
9109   {
9110     char fstype[] = "ext2";
9111     char device[] = "/dev/VG/LV";
9112     int r;
9113     suppress_error = 0;
9114     r = guestfs_mkfs (g, fstype, device);
9115     if (r == -1)
9116       return -1;
9117   }
9118   {
9119     char device[] = "/dev/VG/LV";
9120     char mountpoint[] = "/";
9121     int r;
9122     suppress_error = 0;
9123     r = guestfs_mount (g, device, mountpoint);
9124     if (r == -1)
9125       return -1;
9126   }
9127   /* TestOutputList for pvs (0) */
9128   {
9129     char **r;
9130     int i;
9131     suppress_error = 0;
9132     r = guestfs_pvs (g);
9133     if (r == NULL)
9134       return -1;
9135     if (!r[0]) {
9136       fprintf (stderr, "test_pvs_0: short list returned from command\n");
9137       print_strings (r);
9138       return -1;
9139     }
9140     {
9141       char expected[] = "/dev/sda1";
9142       expected[5] = devchar;
9143       if (strcmp (r[0], expected) != 0) {
9144         fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9145         return -1;
9146       }
9147     }
9148     if (r[1] != NULL) {
9149       fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
9150       print_strings (r);
9151       return -1;
9152     }
9153     for (i = 0; r[i] != NULL; ++i)
9154       free (r[i]);
9155     free (r);
9156   }
9157   return 0;
9158 }
9159
9160 static int test_pvs_1 (void)
9161 {
9162   /* InitEmpty for pvs (1) */
9163   {
9164     char device[] = "/dev/sda";
9165     device[5] = devchar;
9166     int r;
9167     suppress_error = 0;
9168     r = guestfs_blockdev_setrw (g, device);
9169     if (r == -1)
9170       return -1;
9171   }
9172   {
9173     int r;
9174     suppress_error = 0;
9175     r = guestfs_umount_all (g);
9176     if (r == -1)
9177       return -1;
9178   }
9179   {
9180     int r;
9181     suppress_error = 0;
9182     r = guestfs_lvm_remove_all (g);
9183     if (r == -1)
9184       return -1;
9185   }
9186   /* TestOutputList for pvs (1) */
9187   {
9188     char device[] = "/dev/sda";
9189     device[5] = devchar;
9190     char lines_0[] = ",10";
9191     char lines_1[] = ",20";
9192     char lines_2[] = ",";
9193     char *lines[] = {
9194       lines_0,
9195       lines_1,
9196       lines_2,
9197       NULL
9198     };
9199     int r;
9200     suppress_error = 0;
9201     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9202     if (r == -1)
9203       return -1;
9204   }
9205   {
9206     char device[] = "/dev/sda1";
9207     device[5] = devchar;
9208     int r;
9209     suppress_error = 0;
9210     r = guestfs_pvcreate (g, device);
9211     if (r == -1)
9212       return -1;
9213   }
9214   {
9215     char device[] = "/dev/sda2";
9216     device[5] = devchar;
9217     int r;
9218     suppress_error = 0;
9219     r = guestfs_pvcreate (g, device);
9220     if (r == -1)
9221       return -1;
9222   }
9223   {
9224     char device[] = "/dev/sda3";
9225     device[5] = devchar;
9226     int r;
9227     suppress_error = 0;
9228     r = guestfs_pvcreate (g, device);
9229     if (r == -1)
9230       return -1;
9231   }
9232   {
9233     char **r;
9234     int i;
9235     suppress_error = 0;
9236     r = guestfs_pvs (g);
9237     if (r == NULL)
9238       return -1;
9239     if (!r[0]) {
9240       fprintf (stderr, "test_pvs_1: short list returned from command\n");
9241       print_strings (r);
9242       return -1;
9243     }
9244     {
9245       char expected[] = "/dev/sda1";
9246       expected[5] = devchar;
9247       if (strcmp (r[0], expected) != 0) {
9248         fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9249         return -1;
9250       }
9251     }
9252     if (!r[1]) {
9253       fprintf (stderr, "test_pvs_1: short list returned from command\n");
9254       print_strings (r);
9255       return -1;
9256     }
9257     {
9258       char expected[] = "/dev/sda2";
9259       expected[5] = devchar;
9260       if (strcmp (r[1], expected) != 0) {
9261         fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9262         return -1;
9263       }
9264     }
9265     if (!r[2]) {
9266       fprintf (stderr, "test_pvs_1: short list returned from command\n");
9267       print_strings (r);
9268       return -1;
9269     }
9270     {
9271       char expected[] = "/dev/sda3";
9272       expected[5] = devchar;
9273       if (strcmp (r[2], expected) != 0) {
9274         fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9275         return -1;
9276       }
9277     }
9278     if (r[3] != NULL) {
9279       fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
9280       print_strings (r);
9281       return -1;
9282     }
9283     for (i = 0; r[i] != NULL; ++i)
9284       free (r[i]);
9285     free (r);
9286   }
9287   return 0;
9288 }
9289
9290 static int test_list_partitions_0 (void)
9291 {
9292   /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
9293   {
9294     char device[] = "/dev/sda";
9295     device[5] = devchar;
9296     int r;
9297     suppress_error = 0;
9298     r = guestfs_blockdev_setrw (g, device);
9299     if (r == -1)
9300       return -1;
9301   }
9302   {
9303     int r;
9304     suppress_error = 0;
9305     r = guestfs_umount_all (g);
9306     if (r == -1)
9307       return -1;
9308   }
9309   {
9310     int r;
9311     suppress_error = 0;
9312     r = guestfs_lvm_remove_all (g);
9313     if (r == -1)
9314       return -1;
9315   }
9316   {
9317     char device[] = "/dev/sda";
9318     device[5] = devchar;
9319     char lines_0[] = ",";
9320     char *lines[] = {
9321       lines_0,
9322       NULL
9323     };
9324     int r;
9325     suppress_error = 0;
9326     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9327     if (r == -1)
9328       return -1;
9329   }
9330   {
9331     char fstype[] = "ext2";
9332     char device[] = "/dev/sda1";
9333     device[5] = devchar;
9334     int r;
9335     suppress_error = 0;
9336     r = guestfs_mkfs (g, fstype, device);
9337     if (r == -1)
9338       return -1;
9339   }
9340   {
9341     char device[] = "/dev/sda1";
9342     device[5] = devchar;
9343     char mountpoint[] = "/";
9344     int r;
9345     suppress_error = 0;
9346     r = guestfs_mount (g, device, mountpoint);
9347     if (r == -1)
9348       return -1;
9349   }
9350   /* TestOutputList for list_partitions (0) */
9351   {
9352     char **r;
9353     int i;
9354     suppress_error = 0;
9355     r = guestfs_list_partitions (g);
9356     if (r == NULL)
9357       return -1;
9358     if (!r[0]) {
9359       fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
9360       print_strings (r);
9361       return -1;
9362     }
9363     {
9364       char expected[] = "/dev/sda1";
9365       expected[5] = devchar;
9366       if (strcmp (r[0], expected) != 0) {
9367         fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9368         return -1;
9369       }
9370     }
9371     if (r[1] != NULL) {
9372       fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
9373       print_strings (r);
9374       return -1;
9375     }
9376     for (i = 0; r[i] != NULL; ++i)
9377       free (r[i]);
9378     free (r);
9379   }
9380   return 0;
9381 }
9382
9383 static int test_list_partitions_1 (void)
9384 {
9385   /* InitEmpty for list_partitions (1) */
9386   {
9387     char device[] = "/dev/sda";
9388     device[5] = devchar;
9389     int r;
9390     suppress_error = 0;
9391     r = guestfs_blockdev_setrw (g, device);
9392     if (r == -1)
9393       return -1;
9394   }
9395   {
9396     int r;
9397     suppress_error = 0;
9398     r = guestfs_umount_all (g);
9399     if (r == -1)
9400       return -1;
9401   }
9402   {
9403     int r;
9404     suppress_error = 0;
9405     r = guestfs_lvm_remove_all (g);
9406     if (r == -1)
9407       return -1;
9408   }
9409   /* TestOutputList for list_partitions (1) */
9410   {
9411     char device[] = "/dev/sda";
9412     device[5] = devchar;
9413     char lines_0[] = ",10";
9414     char lines_1[] = ",20";
9415     char lines_2[] = ",";
9416     char *lines[] = {
9417       lines_0,
9418       lines_1,
9419       lines_2,
9420       NULL
9421     };
9422     int r;
9423     suppress_error = 0;
9424     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9425     if (r == -1)
9426       return -1;
9427   }
9428   {
9429     char **r;
9430     int i;
9431     suppress_error = 0;
9432     r = guestfs_list_partitions (g);
9433     if (r == NULL)
9434       return -1;
9435     if (!r[0]) {
9436       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9437       print_strings (r);
9438       return -1;
9439     }
9440     {
9441       char expected[] = "/dev/sda1";
9442       expected[5] = devchar;
9443       if (strcmp (r[0], expected) != 0) {
9444         fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9445         return -1;
9446       }
9447     }
9448     if (!r[1]) {
9449       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9450       print_strings (r);
9451       return -1;
9452     }
9453     {
9454       char expected[] = "/dev/sda2";
9455       expected[5] = devchar;
9456       if (strcmp (r[1], expected) != 0) {
9457         fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9458         return -1;
9459       }
9460     }
9461     if (!r[2]) {
9462       fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9463       print_strings (r);
9464       return -1;
9465     }
9466     {
9467       char expected[] = "/dev/sda3";
9468       expected[5] = devchar;
9469       if (strcmp (r[2], expected) != 0) {
9470         fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9471         return -1;
9472       }
9473     }
9474     if (r[3] != NULL) {
9475       fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
9476       print_strings (r);
9477       return -1;
9478     }
9479     for (i = 0; r[i] != NULL; ++i)
9480       free (r[i]);
9481     free (r);
9482   }
9483   return 0;
9484 }
9485
9486 static int test_list_devices_0 (void)
9487 {
9488   /* InitEmpty for list_devices (0) */
9489   {
9490     char device[] = "/dev/sda";
9491     device[5] = devchar;
9492     int r;
9493     suppress_error = 0;
9494     r = guestfs_blockdev_setrw (g, device);
9495     if (r == -1)
9496       return -1;
9497   }
9498   {
9499     int r;
9500     suppress_error = 0;
9501     r = guestfs_umount_all (g);
9502     if (r == -1)
9503       return -1;
9504   }
9505   {
9506     int r;
9507     suppress_error = 0;
9508     r = guestfs_lvm_remove_all (g);
9509     if (r == -1)
9510       return -1;
9511   }
9512   /* TestOutputList for list_devices (0) */
9513   {
9514     char **r;
9515     int i;
9516     suppress_error = 0;
9517     r = guestfs_list_devices (g);
9518     if (r == NULL)
9519       return -1;
9520     if (!r[0]) {
9521       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9522       print_strings (r);
9523       return -1;
9524     }
9525     {
9526       char expected[] = "/dev/sda";
9527       expected[5] = devchar;
9528       if (strcmp (r[0], expected) != 0) {
9529         fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9530         return -1;
9531       }
9532     }
9533     if (!r[1]) {
9534       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9535       print_strings (r);
9536       return -1;
9537     }
9538     {
9539       char expected[] = "/dev/sdb";
9540       expected[5] = devchar;
9541       if (strcmp (r[1], expected) != 0) {
9542         fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9543         return -1;
9544       }
9545     }
9546     if (!r[2]) {
9547       fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9548       print_strings (r);
9549       return -1;
9550     }
9551     {
9552       char expected[] = "/dev/sdc";
9553       expected[5] = devchar;
9554       if (strcmp (r[2], expected) != 0) {
9555         fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9556         return -1;
9557       }
9558     }
9559     if (r[3] != NULL) {
9560       fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
9561       print_strings (r);
9562       return -1;
9563     }
9564     for (i = 0; r[i] != NULL; ++i)
9565       free (r[i]);
9566     free (r);
9567   }
9568   return 0;
9569 }
9570
9571 static int test_ls_0 (void)
9572 {
9573   /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
9574   {
9575     char device[] = "/dev/sda";
9576     device[5] = devchar;
9577     int r;
9578     suppress_error = 0;
9579     r = guestfs_blockdev_setrw (g, device);
9580     if (r == -1)
9581       return -1;
9582   }
9583   {
9584     int r;
9585     suppress_error = 0;
9586     r = guestfs_umount_all (g);
9587     if (r == -1)
9588       return -1;
9589   }
9590   {
9591     int r;
9592     suppress_error = 0;
9593     r = guestfs_lvm_remove_all (g);
9594     if (r == -1)
9595       return -1;
9596   }
9597   {
9598     char device[] = "/dev/sda";
9599     device[5] = devchar;
9600     char lines_0[] = ",";
9601     char *lines[] = {
9602       lines_0,
9603       NULL
9604     };
9605     int r;
9606     suppress_error = 0;
9607     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9608     if (r == -1)
9609       return -1;
9610   }
9611   {
9612     char fstype[] = "ext2";
9613     char device[] = "/dev/sda1";
9614     device[5] = devchar;
9615     int r;
9616     suppress_error = 0;
9617     r = guestfs_mkfs (g, fstype, device);
9618     if (r == -1)
9619       return -1;
9620   }
9621   {
9622     char device[] = "/dev/sda1";
9623     device[5] = devchar;
9624     char mountpoint[] = "/";
9625     int r;
9626     suppress_error = 0;
9627     r = guestfs_mount (g, device, mountpoint);
9628     if (r == -1)
9629       return -1;
9630   }
9631   /* TestOutputList for ls (0) */
9632   {
9633     char path[] = "/new";
9634     int r;
9635     suppress_error = 0;
9636     r = guestfs_touch (g, path);
9637     if (r == -1)
9638       return -1;
9639   }
9640   {
9641     char path[] = "/newer";
9642     int r;
9643     suppress_error = 0;
9644     r = guestfs_touch (g, path);
9645     if (r == -1)
9646       return -1;
9647   }
9648   {
9649     char path[] = "/newest";
9650     int r;
9651     suppress_error = 0;
9652     r = guestfs_touch (g, path);
9653     if (r == -1)
9654       return -1;
9655   }
9656   {
9657     char directory[] = "/";
9658     char **r;
9659     int i;
9660     suppress_error = 0;
9661     r = guestfs_ls (g, directory);
9662     if (r == NULL)
9663       return -1;
9664     if (!r[0]) {
9665       fprintf (stderr, "test_ls_0: short list returned from command\n");
9666       print_strings (r);
9667       return -1;
9668     }
9669     {
9670       char expected[] = "lost+found";
9671       if (strcmp (r[0], expected) != 0) {
9672         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9673         return -1;
9674       }
9675     }
9676     if (!r[1]) {
9677       fprintf (stderr, "test_ls_0: short list returned from command\n");
9678       print_strings (r);
9679       return -1;
9680     }
9681     {
9682       char expected[] = "new";
9683       if (strcmp (r[1], expected) != 0) {
9684         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9685         return -1;
9686       }
9687     }
9688     if (!r[2]) {
9689       fprintf (stderr, "test_ls_0: short list returned from command\n");
9690       print_strings (r);
9691       return -1;
9692     }
9693     {
9694       char expected[] = "newer";
9695       if (strcmp (r[2], expected) != 0) {
9696         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9697         return -1;
9698       }
9699     }
9700     if (!r[3]) {
9701       fprintf (stderr, "test_ls_0: short list returned from command\n");
9702       print_strings (r);
9703       return -1;
9704     }
9705     {
9706       char expected[] = "newest";
9707       if (strcmp (r[3], expected) != 0) {
9708         fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
9709         return -1;
9710       }
9711     }
9712     if (r[4] != NULL) {
9713       fprintf (stderr, "test_ls_0: extra elements returned from command\n");
9714       print_strings (r);
9715       return -1;
9716     }
9717     for (i = 0; r[i] != NULL; ++i)
9718       free (r[i]);
9719     free (r);
9720   }
9721   return 0;
9722 }
9723
9724 static int test_cat_0 (void)
9725 {
9726   /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
9727   {
9728     char device[] = "/dev/sda";
9729     device[5] = devchar;
9730     int r;
9731     suppress_error = 0;
9732     r = guestfs_blockdev_setrw (g, device);
9733     if (r == -1)
9734       return -1;
9735   }
9736   {
9737     int r;
9738     suppress_error = 0;
9739     r = guestfs_umount_all (g);
9740     if (r == -1)
9741       return -1;
9742   }
9743   {
9744     int r;
9745     suppress_error = 0;
9746     r = guestfs_lvm_remove_all (g);
9747     if (r == -1)
9748       return -1;
9749   }
9750   {
9751     char device[] = "/dev/sda";
9752     device[5] = devchar;
9753     char lines_0[] = ",";
9754     char *lines[] = {
9755       lines_0,
9756       NULL
9757     };
9758     int r;
9759     suppress_error = 0;
9760     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9761     if (r == -1)
9762       return -1;
9763   }
9764   {
9765     char fstype[] = "ext2";
9766     char device[] = "/dev/sda1";
9767     device[5] = devchar;
9768     int r;
9769     suppress_error = 0;
9770     r = guestfs_mkfs (g, fstype, device);
9771     if (r == -1)
9772       return -1;
9773   }
9774   {
9775     char device[] = "/dev/sda1";
9776     device[5] = devchar;
9777     char mountpoint[] = "/";
9778     int r;
9779     suppress_error = 0;
9780     r = guestfs_mount (g, device, mountpoint);
9781     if (r == -1)
9782       return -1;
9783   }
9784   /* TestOutput for cat (0) */
9785   char expected[] = "new file contents";
9786   {
9787     char path[] = "/new";
9788     char content[] = "new file contents";
9789     int r;
9790     suppress_error = 0;
9791     r = guestfs_write_file (g, path, content, 0);
9792     if (r == -1)
9793       return -1;
9794   }
9795   {
9796     char path[] = "/new";
9797     char *r;
9798     suppress_error = 0;
9799     r = guestfs_cat (g, path);
9800     if (r == NULL)
9801       return -1;
9802     if (strcmp (r, expected) != 0) {
9803       fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
9804       return -1;
9805     }
9806     free (r);
9807   }
9808   return 0;
9809 }
9810
9811 static int test_touch_0 (void)
9812 {
9813   /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
9814   {
9815     char device[] = "/dev/sda";
9816     device[5] = devchar;
9817     int r;
9818     suppress_error = 0;
9819     r = guestfs_blockdev_setrw (g, device);
9820     if (r == -1)
9821       return -1;
9822   }
9823   {
9824     int r;
9825     suppress_error = 0;
9826     r = guestfs_umount_all (g);
9827     if (r == -1)
9828       return -1;
9829   }
9830   {
9831     int r;
9832     suppress_error = 0;
9833     r = guestfs_lvm_remove_all (g);
9834     if (r == -1)
9835       return -1;
9836   }
9837   {
9838     char device[] = "/dev/sda";
9839     device[5] = devchar;
9840     char lines_0[] = ",";
9841     char *lines[] = {
9842       lines_0,
9843       NULL
9844     };
9845     int r;
9846     suppress_error = 0;
9847     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9848     if (r == -1)
9849       return -1;
9850   }
9851   {
9852     char fstype[] = "ext2";
9853     char device[] = "/dev/sda1";
9854     device[5] = devchar;
9855     int r;
9856     suppress_error = 0;
9857     r = guestfs_mkfs (g, fstype, device);
9858     if (r == -1)
9859       return -1;
9860   }
9861   {
9862     char device[] = "/dev/sda1";
9863     device[5] = devchar;
9864     char mountpoint[] = "/";
9865     int r;
9866     suppress_error = 0;
9867     r = guestfs_mount (g, device, mountpoint);
9868     if (r == -1)
9869       return -1;
9870   }
9871   /* TestOutputTrue for touch (0) */
9872   {
9873     char path[] = "/new";
9874     int r;
9875     suppress_error = 0;
9876     r = guestfs_touch (g, path);
9877     if (r == -1)
9878       return -1;
9879   }
9880   {
9881     char path[] = "/new";
9882     int r;
9883     suppress_error = 0;
9884     r = guestfs_exists (g, path);
9885     if (r == -1)
9886       return -1;
9887     if (!r) {
9888       fprintf (stderr, "test_touch_0: expected true, got false\n");
9889       return -1;
9890     }
9891   }
9892   return 0;
9893 }
9894
9895 static int test_sync_0 (void)
9896 {
9897   /* InitEmpty for sync (0) */
9898   {
9899     char device[] = "/dev/sda";
9900     device[5] = devchar;
9901     int r;
9902     suppress_error = 0;
9903     r = guestfs_blockdev_setrw (g, device);
9904     if (r == -1)
9905       return -1;
9906   }
9907   {
9908     int r;
9909     suppress_error = 0;
9910     r = guestfs_umount_all (g);
9911     if (r == -1)
9912       return -1;
9913   }
9914   {
9915     int r;
9916     suppress_error = 0;
9917     r = guestfs_lvm_remove_all (g);
9918     if (r == -1)
9919       return -1;
9920   }
9921   /* TestRun for sync (0) */
9922   {
9923     int r;
9924     suppress_error = 0;
9925     r = guestfs_sync (g);
9926     if (r == -1)
9927       return -1;
9928   }
9929   return 0;
9930 }
9931
9932 static int test_mount_0 (void)
9933 {
9934   /* InitEmpty for mount (0) */
9935   {
9936     char device[] = "/dev/sda";
9937     device[5] = devchar;
9938     int r;
9939     suppress_error = 0;
9940     r = guestfs_blockdev_setrw (g, device);
9941     if (r == -1)
9942       return -1;
9943   }
9944   {
9945     int r;
9946     suppress_error = 0;
9947     r = guestfs_umount_all (g);
9948     if (r == -1)
9949       return -1;
9950   }
9951   {
9952     int r;
9953     suppress_error = 0;
9954     r = guestfs_lvm_remove_all (g);
9955     if (r == -1)
9956       return -1;
9957   }
9958   /* TestOutput for mount (0) */
9959   char expected[] = "new file contents";
9960   {
9961     char device[] = "/dev/sda";
9962     device[5] = devchar;
9963     char lines_0[] = ",";
9964     char *lines[] = {
9965       lines_0,
9966       NULL
9967     };
9968     int r;
9969     suppress_error = 0;
9970     r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9971     if (r == -1)
9972       return -1;
9973   }
9974   {
9975     char fstype[] = "ext2";
9976     char device[] = "/dev/sda1";
9977     device[5] = devchar;
9978     int r;
9979     suppress_error = 0;
9980     r = guestfs_mkfs (g, fstype, device);
9981     if (r == -1)
9982       return -1;
9983   }
9984   {
9985     char device[] = "/dev/sda1";
9986     device[5] = devchar;
9987     char mountpoint[] = "/";
9988     int r;
9989     suppress_error = 0;
9990     r = guestfs_mount (g, device, mountpoint);
9991     if (r == -1)
9992       return -1;
9993   }
9994   {
9995     char path[] = "/new";
9996     char content[] = "new file contents";
9997     int r;
9998     suppress_error = 0;
9999     r = guestfs_write_file (g, path, content, 0);
10000     if (r == -1)
10001       return -1;
10002   }
10003   {
10004     char path[] = "/new";
10005     char *r;
10006     suppress_error = 0;
10007     r = guestfs_cat (g, path);
10008     if (r == NULL)
10009       return -1;
10010     if (strcmp (r, expected) != 0) {
10011       fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
10012       return -1;
10013     }
10014     free (r);
10015   }
10016   return 0;
10017 }
10018
10019 int main (int argc, char *argv[])
10020 {
10021   char c = 0;
10022   int failed = 0;
10023   const char *srcdir;
10024   const char *filename;
10025   int fd, i;
10026   int nr_tests, test_num = 0;
10027   char **devs;
10028
10029   no_test_warnings ();
10030
10031   g = guestfs_create ();
10032   if (g == NULL) {
10033     printf ("guestfs_create FAILED\n");
10034     exit (1);
10035   }
10036
10037   guestfs_set_error_handler (g, print_error, NULL);
10038
10039   srcdir = getenv ("srcdir");
10040   if (!srcdir) srcdir = ".";
10041   chdir (srcdir);
10042   guestfs_set_path (g, ".");
10043
10044   filename = "test1.img";
10045   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10046   if (fd == -1) {
10047     perror (filename);
10048     exit (1);
10049   }
10050   if (lseek (fd, 524288000, SEEK_SET) == -1) {
10051     perror ("lseek");
10052     close (fd);
10053     unlink (filename);
10054     exit (1);
10055   }
10056   if (write (fd, &c, 1) == -1) {
10057     perror ("write");
10058     close (fd);
10059     unlink (filename);
10060     exit (1);
10061   }
10062   if (close (fd) == -1) {
10063     perror (filename);
10064     unlink (filename);
10065     exit (1);
10066   }
10067   if (guestfs_add_drive (g, filename) == -1) {
10068     printf ("guestfs_add_drive %s FAILED\n", filename);
10069     exit (1);
10070   }
10071
10072   filename = "test2.img";
10073   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10074   if (fd == -1) {
10075     perror (filename);
10076     exit (1);
10077   }
10078   if (lseek (fd, 52428800, SEEK_SET) == -1) {
10079     perror ("lseek");
10080     close (fd);
10081     unlink (filename);
10082     exit (1);
10083   }
10084   if (write (fd, &c, 1) == -1) {
10085     perror ("write");
10086     close (fd);
10087     unlink (filename);
10088     exit (1);
10089   }
10090   if (close (fd) == -1) {
10091     perror (filename);
10092     unlink (filename);
10093     exit (1);
10094   }
10095   if (guestfs_add_drive (g, filename) == -1) {
10096     printf ("guestfs_add_drive %s FAILED\n", filename);
10097     exit (1);
10098   }
10099
10100   filename = "test3.img";
10101   fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10102   if (fd == -1) {
10103     perror (filename);
10104     exit (1);
10105   }
10106   if (lseek (fd, 10485760, SEEK_SET) == -1) {
10107     perror ("lseek");
10108     close (fd);
10109     unlink (filename);
10110     exit (1);
10111   }
10112   if (write (fd, &c, 1) == -1) {
10113     perror ("write");
10114     close (fd);
10115     unlink (filename);
10116     exit (1);
10117   }
10118   if (close (fd) == -1) {
10119     perror (filename);
10120     unlink (filename);
10121     exit (1);
10122   }
10123   if (guestfs_add_drive (g, filename) == -1) {
10124     printf ("guestfs_add_drive %s FAILED\n", filename);
10125     exit (1);
10126   }
10127
10128   if (guestfs_launch (g) == -1) {
10129     printf ("guestfs_launch FAILED\n");
10130     exit (1);
10131   }
10132   if (guestfs_wait_ready (g) == -1) {
10133     printf ("guestfs_wait_ready FAILED\n");
10134     exit (1);
10135   }
10136
10137   /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
10138    * names.  This changed between RHEL 5 and RHEL 6 so we have to
10139    * support both.
10140    */
10141   devs = guestfs_list_devices (g);
10142   if (devs == NULL || devs[0] == NULL) {
10143     printf ("guestfs_list_devices FAILED\n");
10144     exit (1);
10145   }
10146   if (strncmp (devs[0], "/dev/sd", 7) == 0)
10147     devchar = 's';
10148   else if (strncmp (devs[0], "/dev/hd", 7) == 0)
10149     devchar = 'h';
10150   else {
10151     printf ("guestfs_list_devices returned unexpected string '%s'\n",
10152             devs[0]);
10153     exit (1);
10154   }
10155   for (i = 0; devs[i] != NULL; ++i)
10156     free (devs[i]);
10157   free (devs);
10158
10159   nr_tests = 110;
10160
10161   test_num++;
10162   printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
10163   if (test_hexdump_0 () == -1) {
10164     printf ("test_hexdump_0 FAILED\n");
10165     failed++;
10166   }
10167   test_num++;
10168   printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
10169   if (test_strings_e_0 () == -1) {
10170     printf ("test_strings_e_0 FAILED\n");
10171     failed++;
10172   }
10173   test_num++;
10174   printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
10175   if (test_strings_0 () == -1) {
10176     printf ("test_strings_0 FAILED\n");
10177     failed++;
10178   }
10179   test_num++;
10180   printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
10181   if (test_equal_0 () == -1) {
10182     printf ("test_equal_0 FAILED\n");
10183     failed++;
10184   }
10185   test_num++;
10186   printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
10187   if (test_equal_1 () == -1) {
10188     printf ("test_equal_1 FAILED\n");
10189     failed++;
10190   }
10191   test_num++;
10192   printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
10193   if (test_equal_2 () == -1) {
10194     printf ("test_equal_2 FAILED\n");
10195     failed++;
10196   }
10197   test_num++;
10198   printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
10199   if (test_ping_daemon_0 () == -1) {
10200     printf ("test_ping_daemon_0 FAILED\n");
10201     failed++;
10202   }
10203   test_num++;
10204   printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
10205   if (test_dmesg_0 () == -1) {
10206     printf ("test_dmesg_0 FAILED\n");
10207     failed++;
10208   }
10209   test_num++;
10210   printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
10211   if (test_drop_caches_0 () == -1) {
10212     printf ("test_drop_caches_0 FAILED\n");
10213     failed++;
10214   }
10215   test_num++;
10216   printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
10217   if (test_mv_0 () == -1) {
10218     printf ("test_mv_0 FAILED\n");
10219     failed++;
10220   }
10221   test_num++;
10222   printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
10223   if (test_mv_1 () == -1) {
10224     printf ("test_mv_1 FAILED\n");
10225     failed++;
10226   }
10227   test_num++;
10228   printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
10229   if (test_cp_a_0 () == -1) {
10230     printf ("test_cp_a_0 FAILED\n");
10231     failed++;
10232   }
10233   test_num++;
10234   printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
10235   if (test_cp_0 () == -1) {
10236     printf ("test_cp_0 FAILED\n");
10237     failed++;
10238   }
10239   test_num++;
10240   printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
10241   if (test_cp_1 () == -1) {
10242     printf ("test_cp_1 FAILED\n");
10243     failed++;
10244   }
10245   test_num++;
10246   printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
10247   if (test_cp_2 () == -1) {
10248     printf ("test_cp_2 FAILED\n");
10249     failed++;
10250   }
10251   test_num++;
10252   printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
10253   if (test_grub_install_0 () == -1) {
10254     printf ("test_grub_install_0 FAILED\n");
10255     failed++;
10256   }
10257   test_num++;
10258   printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
10259   if (test_zero_0 () == -1) {
10260     printf ("test_zero_0 FAILED\n");
10261     failed++;
10262   }
10263   test_num++;
10264   printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
10265   if (test_fsck_0 () == -1) {
10266     printf ("test_fsck_0 FAILED\n");
10267     failed++;
10268   }
10269   test_num++;
10270   printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
10271   if (test_fsck_1 () == -1) {
10272     printf ("test_fsck_1 FAILED\n");
10273     failed++;
10274   }
10275   test_num++;
10276   printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
10277   if (test_set_e2uuid_0 () == -1) {
10278     printf ("test_set_e2uuid_0 FAILED\n");
10279     failed++;
10280   }
10281   test_num++;
10282   printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
10283   if (test_set_e2uuid_1 () == -1) {
10284     printf ("test_set_e2uuid_1 FAILED\n");
10285     failed++;
10286   }
10287   test_num++;
10288   printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
10289   if (test_set_e2uuid_2 () == -1) {
10290     printf ("test_set_e2uuid_2 FAILED\n");
10291     failed++;
10292   }
10293   test_num++;
10294   printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
10295   if (test_set_e2uuid_3 () == -1) {
10296     printf ("test_set_e2uuid_3 FAILED\n");
10297     failed++;
10298   }
10299   test_num++;
10300   printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
10301   if (test_set_e2label_0 () == -1) {
10302     printf ("test_set_e2label_0 FAILED\n");
10303     failed++;
10304   }
10305   test_num++;
10306   printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
10307   if (test_pvremove_0 () == -1) {
10308     printf ("test_pvremove_0 FAILED\n");
10309     failed++;
10310   }
10311   test_num++;
10312   printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
10313   if (test_pvremove_1 () == -1) {
10314     printf ("test_pvremove_1 FAILED\n");
10315     failed++;
10316   }
10317   test_num++;
10318   printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
10319   if (test_pvremove_2 () == -1) {
10320     printf ("test_pvremove_2 FAILED\n");
10321     failed++;
10322   }
10323   test_num++;
10324   printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
10325   if (test_vgremove_0 () == -1) {
10326     printf ("test_vgremove_0 FAILED\n");
10327     failed++;
10328   }
10329   test_num++;
10330   printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
10331   if (test_vgremove_1 () == -1) {
10332     printf ("test_vgremove_1 FAILED\n");
10333     failed++;
10334   }
10335   test_num++;
10336   printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
10337   if (test_lvremove_0 () == -1) {
10338     printf ("test_lvremove_0 FAILED\n");
10339     failed++;
10340   }
10341   test_num++;
10342   printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
10343   if (test_lvremove_1 () == -1) {
10344     printf ("test_lvremove_1 FAILED\n");
10345     failed++;
10346   }
10347   test_num++;
10348   printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
10349   if (test_lvremove_2 () == -1) {
10350     printf ("test_lvremove_2 FAILED\n");
10351     failed++;
10352   }
10353   test_num++;
10354   printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
10355   if (test_mount_ro_0 () == -1) {
10356     printf ("test_mount_ro_0 FAILED\n");
10357     failed++;
10358   }
10359   test_num++;
10360   printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
10361   if (test_mount_ro_1 () == -1) {
10362     printf ("test_mount_ro_1 FAILED\n");
10363     failed++;
10364   }
10365   test_num++;
10366   printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
10367   if (test_tgz_in_0 () == -1) {
10368     printf ("test_tgz_in_0 FAILED\n");
10369     failed++;
10370   }
10371   test_num++;
10372   printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
10373   if (test_tar_in_0 () == -1) {
10374     printf ("test_tar_in_0 FAILED\n");
10375     failed++;
10376   }
10377   test_num++;
10378   printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
10379   if (test_checksum_0 () == -1) {
10380     printf ("test_checksum_0 FAILED\n");
10381     failed++;
10382   }
10383   test_num++;
10384   printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
10385   if (test_checksum_1 () == -1) {
10386     printf ("test_checksum_1 FAILED\n");
10387     failed++;
10388   }
10389   test_num++;
10390   printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
10391   if (test_checksum_2 () == -1) {
10392     printf ("test_checksum_2 FAILED\n");
10393     failed++;
10394   }
10395   test_num++;
10396   printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
10397   if (test_checksum_3 () == -1) {
10398     printf ("test_checksum_3 FAILED\n");
10399     failed++;
10400   }
10401   test_num++;
10402   printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
10403   if (test_checksum_4 () == -1) {
10404     printf ("test_checksum_4 FAILED\n");
10405     failed++;
10406   }
10407   test_num++;
10408   printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
10409   if (test_checksum_5 () == -1) {
10410     printf ("test_checksum_5 FAILED\n");
10411     failed++;
10412   }
10413   test_num++;
10414   printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
10415   if (test_checksum_6 () == -1) {
10416     printf ("test_checksum_6 FAILED\n");
10417     failed++;
10418   }
10419   test_num++;
10420   printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
10421   if (test_checksum_7 () == -1) {
10422     printf ("test_checksum_7 FAILED\n");
10423     failed++;
10424   }
10425   test_num++;
10426   printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
10427   if (test_download_0 () == -1) {
10428     printf ("test_download_0 FAILED\n");
10429     failed++;
10430   }
10431   test_num++;
10432   printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
10433   if (test_upload_0 () == -1) {
10434     printf ("test_upload_0 FAILED\n");
10435     failed++;
10436   }
10437   test_num++;
10438   printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
10439   if (test_blockdev_rereadpt_0 () == -1) {
10440     printf ("test_blockdev_rereadpt_0 FAILED\n");
10441     failed++;
10442   }
10443   test_num++;
10444   printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
10445   if (test_blockdev_flushbufs_0 () == -1) {
10446     printf ("test_blockdev_flushbufs_0 FAILED\n");
10447     failed++;
10448   }
10449   test_num++;
10450   printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
10451   if (test_blockdev_getsize64_0 () == -1) {
10452     printf ("test_blockdev_getsize64_0 FAILED\n");
10453     failed++;
10454   }
10455   test_num++;
10456   printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
10457   if (test_blockdev_getsz_0 () == -1) {
10458     printf ("test_blockdev_getsz_0 FAILED\n");
10459     failed++;
10460   }
10461   test_num++;
10462   printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
10463   if (test_blockdev_getbsz_0 () == -1) {
10464     printf ("test_blockdev_getbsz_0 FAILED\n");
10465     failed++;
10466   }
10467   test_num++;
10468   printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
10469   if (test_blockdev_getss_0 () == -1) {
10470     printf ("test_blockdev_getss_0 FAILED\n");
10471     failed++;
10472   }
10473   test_num++;
10474   printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
10475   if (test_blockdev_getro_0 () == -1) {
10476     printf ("test_blockdev_getro_0 FAILED\n");
10477     failed++;
10478   }
10479   test_num++;
10480   printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
10481   if (test_blockdev_setrw_0 () == -1) {
10482     printf ("test_blockdev_setrw_0 FAILED\n");
10483     failed++;
10484   }
10485   test_num++;
10486   printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
10487   if (test_blockdev_setro_0 () == -1) {
10488     printf ("test_blockdev_setro_0 FAILED\n");
10489     failed++;
10490   }
10491   test_num++;
10492   printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
10493   if (test_statvfs_0 () == -1) {
10494     printf ("test_statvfs_0 FAILED\n");
10495     failed++;
10496   }
10497   test_num++;
10498   printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
10499   if (test_lstat_0 () == -1) {
10500     printf ("test_lstat_0 FAILED\n");
10501     failed++;
10502   }
10503   test_num++;
10504   printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
10505   if (test_stat_0 () == -1) {
10506     printf ("test_stat_0 FAILED\n");
10507     failed++;
10508   }
10509   test_num++;
10510   printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
10511   if (test_file_0 () == -1) {
10512     printf ("test_file_0 FAILED\n");
10513     failed++;
10514   }
10515   test_num++;
10516   printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
10517   if (test_file_1 () == -1) {
10518     printf ("test_file_1 FAILED\n");
10519     failed++;
10520   }
10521   test_num++;
10522   printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
10523   if (test_file_2 () == -1) {
10524     printf ("test_file_2 FAILED\n");
10525     failed++;
10526   }
10527   test_num++;
10528   printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
10529   if (test_umount_all_0 () == -1) {
10530     printf ("test_umount_all_0 FAILED\n");
10531     failed++;
10532   }
10533   test_num++;
10534   printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
10535   if (test_umount_all_1 () == -1) {
10536     printf ("test_umount_all_1 FAILED\n");
10537     failed++;
10538   }
10539   test_num++;
10540   printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
10541   if (test_mounts_0 () == -1) {
10542     printf ("test_mounts_0 FAILED\n");
10543     failed++;
10544   }
10545   test_num++;
10546   printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
10547   if (test_umount_0 () == -1) {
10548     printf ("test_umount_0 FAILED\n");
10549     failed++;
10550   }
10551   test_num++;
10552   printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
10553   if (test_umount_1 () == -1) {
10554     printf ("test_umount_1 FAILED\n");
10555     failed++;
10556   }
10557   test_num++;
10558   printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
10559   if (test_write_file_0 () == -1) {
10560     printf ("test_write_file_0 FAILED\n");
10561     failed++;
10562   }
10563   test_num++;
10564   printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
10565   if (test_write_file_1 () == -1) {
10566     printf ("test_write_file_1 FAILED\n");
10567     failed++;
10568   }
10569   test_num++;
10570   printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
10571   if (test_write_file_2 () == -1) {
10572     printf ("test_write_file_2 FAILED\n");
10573     failed++;
10574   }
10575   test_num++;
10576   printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
10577   if (test_write_file_3 () == -1) {
10578     printf ("test_write_file_3 FAILED\n");
10579     failed++;
10580   }
10581   test_num++;
10582   printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
10583   if (test_write_file_4 () == -1) {
10584     printf ("test_write_file_4 FAILED\n");
10585     failed++;
10586   }
10587   test_num++;
10588   printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
10589   if (test_write_file_5 () == -1) {
10590     printf ("test_write_file_5 FAILED\n");
10591     failed++;
10592   }
10593   test_num++;
10594   printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
10595   if (test_mkfs_0 () == -1) {
10596     printf ("test_mkfs_0 FAILED\n");
10597     failed++;
10598   }
10599   test_num++;
10600   printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
10601   if (test_lvcreate_0 () == -1) {
10602     printf ("test_lvcreate_0 FAILED\n");
10603     failed++;
10604   }
10605   test_num++;
10606   printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
10607   if (test_vgcreate_0 () == -1) {
10608     printf ("test_vgcreate_0 FAILED\n");
10609     failed++;
10610   }
10611   test_num++;
10612   printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
10613   if (test_pvcreate_0 () == -1) {
10614     printf ("test_pvcreate_0 FAILED\n");
10615     failed++;
10616   }
10617   test_num++;
10618   printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
10619   if (test_is_dir_0 () == -1) {
10620     printf ("test_is_dir_0 FAILED\n");
10621     failed++;
10622   }
10623   test_num++;
10624   printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
10625   if (test_is_dir_1 () == -1) {
10626     printf ("test_is_dir_1 FAILED\n");
10627     failed++;
10628   }
10629   test_num++;
10630   printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
10631   if (test_is_file_0 () == -1) {
10632     printf ("test_is_file_0 FAILED\n");
10633     failed++;
10634   }
10635   test_num++;
10636   printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
10637   if (test_is_file_1 () == -1) {
10638     printf ("test_is_file_1 FAILED\n");
10639     failed++;
10640   }
10641   test_num++;
10642   printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
10643   if (test_exists_0 () == -1) {
10644     printf ("test_exists_0 FAILED\n");
10645     failed++;
10646   }
10647   test_num++;
10648   printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
10649   if (test_exists_1 () == -1) {
10650     printf ("test_exists_1 FAILED\n");
10651     failed++;
10652   }
10653   test_num++;
10654   printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
10655   if (test_mkdir_p_0 () == -1) {
10656     printf ("test_mkdir_p_0 FAILED\n");
10657     failed++;
10658   }
10659   test_num++;
10660   printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
10661   if (test_mkdir_p_1 () == -1) {
10662     printf ("test_mkdir_p_1 FAILED\n");
10663     failed++;
10664   }
10665   test_num++;
10666   printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
10667   if (test_mkdir_p_2 () == -1) {
10668     printf ("test_mkdir_p_2 FAILED\n");
10669     failed++;
10670   }
10671   test_num++;
10672   printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
10673   if (test_mkdir_0 () == -1) {
10674     printf ("test_mkdir_0 FAILED\n");
10675     failed++;
10676   }
10677   test_num++;
10678   printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
10679   if (test_mkdir_1 () == -1) {
10680     printf ("test_mkdir_1 FAILED\n");
10681     failed++;
10682   }
10683   test_num++;
10684   printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
10685   if (test_rm_rf_0 () == -1) {
10686     printf ("test_rm_rf_0 FAILED\n");
10687     failed++;
10688   }
10689   test_num++;
10690   printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
10691   if (test_rmdir_0 () == -1) {
10692     printf ("test_rmdir_0 FAILED\n");
10693     failed++;
10694   }
10695   test_num++;
10696   printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
10697   if (test_rmdir_1 () == -1) {
10698     printf ("test_rmdir_1 FAILED\n");
10699     failed++;
10700   }
10701   test_num++;
10702   printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
10703   if (test_rmdir_2 () == -1) {
10704     printf ("test_rmdir_2 FAILED\n");
10705     failed++;
10706   }
10707   test_num++;
10708   printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
10709   if (test_rm_0 () == -1) {
10710     printf ("test_rm_0 FAILED\n");
10711     failed++;
10712   }
10713   test_num++;
10714   printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
10715   if (test_rm_1 () == -1) {
10716     printf ("test_rm_1 FAILED\n");
10717     failed++;
10718   }
10719   test_num++;
10720   printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
10721   if (test_rm_2 () == -1) {
10722     printf ("test_rm_2 FAILED\n");
10723     failed++;
10724   }
10725   test_num++;
10726   printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
10727   if (test_read_lines_0 () == -1) {
10728     printf ("test_read_lines_0 FAILED\n");
10729     failed++;
10730   }
10731   test_num++;
10732   printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
10733   if (test_read_lines_1 () == -1) {
10734     printf ("test_read_lines_1 FAILED\n");
10735     failed++;
10736   }
10737   test_num++;
10738   printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
10739   if (test_lvs_0 () == -1) {
10740     printf ("test_lvs_0 FAILED\n");
10741     failed++;
10742   }
10743   test_num++;
10744   printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
10745   if (test_lvs_1 () == -1) {
10746     printf ("test_lvs_1 FAILED\n");
10747     failed++;
10748   }
10749   test_num++;
10750   printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
10751   if (test_vgs_0 () == -1) {
10752     printf ("test_vgs_0 FAILED\n");
10753     failed++;
10754   }
10755   test_num++;
10756   printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
10757   if (test_vgs_1 () == -1) {
10758     printf ("test_vgs_1 FAILED\n");
10759     failed++;
10760   }
10761   test_num++;
10762   printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
10763   if (test_pvs_0 () == -1) {
10764     printf ("test_pvs_0 FAILED\n");
10765     failed++;
10766   }
10767   test_num++;
10768   printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
10769   if (test_pvs_1 () == -1) {
10770     printf ("test_pvs_1 FAILED\n");
10771     failed++;
10772   }
10773   test_num++;
10774   printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
10775   if (test_list_partitions_0 () == -1) {
10776     printf ("test_list_partitions_0 FAILED\n");
10777     failed++;
10778   }
10779   test_num++;
10780   printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
10781   if (test_list_partitions_1 () == -1) {
10782     printf ("test_list_partitions_1 FAILED\n");
10783     failed++;
10784   }
10785   test_num++;
10786   printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
10787   if (test_list_devices_0 () == -1) {
10788     printf ("test_list_devices_0 FAILED\n");
10789     failed++;
10790   }
10791   test_num++;
10792   printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
10793   if (test_ls_0 () == -1) {
10794     printf ("test_ls_0 FAILED\n");
10795     failed++;
10796   }
10797   test_num++;
10798   printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
10799   if (test_cat_0 () == -1) {
10800     printf ("test_cat_0 FAILED\n");
10801     failed++;
10802   }
10803   test_num++;
10804   printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
10805   if (test_touch_0 () == -1) {
10806     printf ("test_touch_0 FAILED\n");
10807     failed++;
10808   }
10809   test_num++;
10810   printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
10811   if (test_sync_0 () == -1) {
10812     printf ("test_sync_0 FAILED\n");
10813     failed++;
10814   }
10815   test_num++;
10816   printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
10817   if (test_mount_0 () == -1) {
10818     printf ("test_mount_0 FAILED\n");
10819     failed++;
10820   }
10821
10822   guestfs_close (g);
10823   unlink ("test1.img");
10824   unlink ("test2.img");
10825   unlink ("test3.img");
10826
10827   if (failed > 0) {
10828     printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);
10829     exit (1);
10830   }
10831
10832   exit (0);
10833 }