+ /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutput for file (0) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_touch (g, "/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *r;
+ suppress_error = 0;
+ r = guestfs_file (g, "/new");
+ if (r == NULL)
+ return -1;
+ if (strcmp (r, "empty") != 0) {
+ fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+static int test_file_1 (void)
+{
+ /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutput for file (1) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_write_file (g, "/new", "some content\n", 0);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *r;
+ suppress_error = 0;
+ r = guestfs_file (g, "/new");
+ if (r == NULL)
+ return -1;
+ if (strcmp (r, "ASCII text") != 0) {
+ fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+static int test_file_2 (void)
+{
+ /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestLastFail for file (2) */
+ {
+ char *r;
+ suppress_error = 1;
+ r = guestfs_file (g, "/nofile");
+ if (r != NULL)
+ return -1;
+ free (r);
+ }
+ return 0;
+}
+
+static int test_stat_0 (void)
+{
+ /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutputStruct for stat (0) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_touch (g, "/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ struct guestfs_stat *r;
+ suppress_error = 0;
+ r = guestfs_stat (g, "/new");
+ if (r == NULL)
+ return -1;
+ if (r->size != 0) {
+ fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
+ (int) r->size);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+static int test_lstat_0 (void)
+{
+ /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutputStruct for lstat (0) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_touch (g, "/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ struct guestfs_stat *r;
+ suppress_error = 0;
+ r = guestfs_lstat (g, "/new");
+ if (r == NULL)
+ return -1;
+ if (r->size != 0) {
+ fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
+ (int) r->size);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+static int test_statvfs_0 (void)
+{
+ /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutputStruct for statvfs (0) */
+ {
+ struct guestfs_statvfs *r;
+ suppress_error = 0;
+ r = guestfs_statvfs (g, "/");
+ if (r == NULL)
+ return -1;
+ if (r->bfree != 487702) {
+ fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
+ (int) r->bfree);
+ return -1;
+ }
+ if (r->blocks != 490020) {
+ fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
+ (int) r->blocks);
+ return -1;
+ }
+ if (r->bsize != 1024) {
+ fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
+ (int) r->bsize);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+int main (int argc, char *argv[])
+{
+ char c = 0;
+ int failed = 0;