summaryrefslogtreecommitdiffstats
path: root/capitests
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-07-02 11:38:36 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-07-02 11:51:16 +0100
commitb3cb0b04eb2d38ba32c160a83d8e3894b376907b (patch)
treee626b236e7d4bc5a4f50888b4f41aaad7c9bd844 /capitests
parentda85ed425dc828ef4b8817f64d448101a88507b5 (diff)
downloadlibguestfs-b3cb0b04eb2d38ba32c160a83d8e3894b376907b.tar.gz
libguestfs-b3cb0b04eb2d38ba32c160a83d8e3894b376907b.tar.xz
libguestfs-b3cb0b04eb2d38ba32c160a83d8e3894b376907b.zip
Remove generated code from git.
Git users now require the OCaml compiler in order to regenerate the generated code after a checkout. Generated code will remain in the tarball, so users of the source tarball will not need the OCaml compiler.
Diffstat (limited to 'capitests')
-rw-r--r--capitests/tests.c20465
1 files changed, 0 insertions, 20465 deletions
diff --git a/capitests/tests.c b/capitests/tests.c
deleted file mode 100644
index 9124ea99..00000000
--- a/capitests/tests.c
+++ /dev/null
@@ -1,20465 +0,0 @@
-/* libguestfs generated file
- * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
- * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-
-#include "guestfs.h"
-
-static guestfs_h *g;
-static int suppress_error = 0;
-
-static void print_error (guestfs_h *g, void *data, const char *msg)
-{
- if (!suppress_error)
- fprintf (stderr, "%s\n", msg);
-}
-
-static void print_strings (char * const * const argv)
-{
- int argc;
-
- for (argc = 0; argv[argc] != NULL; ++argc)
- printf ("\t%s\n", argv[argc]);
-}
-
-/*
-static void print_table (char * const * const argv)
-{
- int i;
-
- for (i = 0; argv[i] != NULL; i += 2)
- printf ("%s: %s\n", argv[i], argv[i+1]);
-}
-*/
-
-static void no_test_warnings (void)
-{
- fprintf (stderr, "warning: \"guestfs_test0\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rint\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rinterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rint64\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rint64err\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rbool\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rboolerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rconststring\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rconststringerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstring\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstringerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstringlist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstringlisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rintbool\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rintboolerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rpvlist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rpvlisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rvglist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rvglisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rlvlist\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rlvlisterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstat\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstaterr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstatvfs\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rstatvfserr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rhashtable\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_test0rhashtableerr\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_add_drive_ro\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_append\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_append\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_set_memsize\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_memsize\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_pvresize\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_N\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_l\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_kernel_geometry\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sfdisk_disk_geometry\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_vg_activate_all\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_vg_activate\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_resize2fs\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sh\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_sh_lines\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_scrub_freespace\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_df\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_df_h\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_mount_loop\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_umask\" has no tests\n");
- fprintf (stderr, "warning: \"guestfs_readdir\" has no tests\n");
-}
-
-static int test_mknod_c_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod_c") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_C_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD_C");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_c_0 (void)
-{
- if (test_mknod_c_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_c_0");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_c_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod_c (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod_c (g, 511, 99, 66, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 8685) {
- fprintf (stderr, "test_mknod_c_0: mode was %d, expected 8685\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mknod_b_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod_b") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_B_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD_B");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_b_0 (void)
-{
- if (test_mknod_b_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_b_0");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_b_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod_b (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod_b (g, 511, 99, 66, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 25069) {
- fprintf (stderr, "test_mknod_b_0: mode was %d, expected 25069\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mkfifo_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkfifo") == NULL;
- str = getenv ("SKIP_TEST_MKFIFO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKFIFO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkfifo_0 (void)
-{
- if (test_mkfifo_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkfifo_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkfifo_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mkfifo (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mkfifo (g, 511, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 4589) {
- fprintf (stderr, "test_mkfifo_0: mode was %d, expected 4589\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mknod_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_0 (void)
-{
- if (test_mknod_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_0");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod (0) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod (g, 4607, 0, 0, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 4589) {
- fprintf (stderr, "test_mknod_0: mode was %d, expected 4589\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mknod_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mknod") == NULL;
- str = getenv ("SKIP_TEST_MKNOD_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKNOD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mknod_1 (void)
-{
- if (test_mknod_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mknod_1");
- return 0;
- }
-
- /* InitBasicFS for test_mknod_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for mknod (1) */
- {
- char path[] = "/node";
- int r;
- suppress_error = 0;
- r = guestfs_mknod (g, 25087, 66, 99, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/node";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- if (r == NULL)
- return -1;
- if (r->mode != 25069) {
- fprintf (stderr, "test_mknod_1: mode was %d, expected 25069\n",
- (int) r->mode);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mkswap_U_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkswap_U") == NULL;
- str = getenv ("SKIP_TEST_MKSWAP_U_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKSWAP_U");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkswap_U_0 (void)
-{
- if (test_mkswap_U_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkswap_U_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkswap_U_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for mkswap_U (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkswap_U (g, uuid, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkswap_L_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkswap_L") == NULL;
- str = getenv ("SKIP_TEST_MKSWAP_L_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKSWAP_L");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkswap_L_0 (void)
-{
- if (test_mkswap_L_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkswap_L_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkswap_L_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for mkswap_L (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char label[] = "hello";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkswap_L (g, label, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkswap_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkswap") == NULL;
- str = getenv ("SKIP_TEST_MKSWAP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKSWAP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkswap_0 (void)
-{
- if (test_mkswap_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkswap_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkswap_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for mkswap (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkswap (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_initrd_list_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "initrd_list") == NULL;
- str = getenv ("SKIP_TEST_INITRD_LIST_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_INITRD_LIST");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_initrd_list_0 (void)
-{
- if (test_initrd_list_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_initrd_list_0");
- return 0;
- }
-
- /* InitBasicFS for test_initrd_list_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for initrd_list (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/initrd";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_initrd_list (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "empty";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "known-1";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "known-2";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_initrd_list_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "known-3";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_initrd_list_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_initrd_list_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_du_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "du") == NULL;
- str = getenv ("SKIP_TEST_DU_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DU");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_du_0 (void)
-{
- if (test_du_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_du_0");
- return 0;
- }
-
- /* InitBasicFS for test_du_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for du (0) */
- {
- char path[] = "/p";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/p";
- int64_t r;
- suppress_error = 0;
- r = guestfs_du (g, path);
- if (r == -1)
- return -1;
- if (r != 1) {
- fprintf (stderr, "test_du_0: expected 1 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_tail_n_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail_n") == NULL;
- str = getenv ("SKIP_TEST_TAIL_N_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_n_0 (void)
-{
- if (test_tail_n_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_n_0");
- return 0;
- }
-
- /* InitBasicFS for test_tail_n_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail_n (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail_n (g, 3, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_tail_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9997abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_tail_n_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_tail_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9998abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_tail_n_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_tail_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9999abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_tail_n_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_tail_n_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_tail_n_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail_n") == NULL;
- str = getenv ("SKIP_TEST_TAIL_N_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_n_1 (void)
-{
- if (test_tail_n_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_n_1");
- return 0;
- }
-
- /* InitBasicFS for test_tail_n_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail_n (1) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail_n (g, -9998, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_tail_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9997abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_tail_n_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_tail_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9998abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_tail_n_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_tail_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9999abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_tail_n_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_tail_n_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_tail_n_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail_n") == NULL;
- str = getenv ("SKIP_TEST_TAIL_N_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_n_2 (void)
-{
- if (test_tail_n_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_n_2");
- return 0;
- }
-
- /* InitBasicFS for test_tail_n_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail_n (2) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail_n (g, 0, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_tail_n_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_tail_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tail") == NULL;
- str = getenv ("SKIP_TEST_TAIL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAIL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tail_0 (void)
-{
- if (test_tail_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tail_0");
- return 0;
- }
-
- /* InitBasicFS for test_tail_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for tail (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_tail (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9990abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9991abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9992abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9993abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (!r[4]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9994abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[4], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
- return -1;
- }
- }
- if (!r[5]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9995abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[5], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[5]);
- return -1;
- }
- }
- if (!r[6]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9996abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[6], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[6]);
- return -1;
- }
- }
- if (!r[7]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9997abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[7], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[7]);
- return -1;
- }
- }
- if (!r[8]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9998abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[8], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[8]);
- return -1;
- }
- }
- if (!r[9]) {
- fprintf (stderr, "test_tail_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9999abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[9], expected) != 0) {
- fprintf (stderr, "test_tail_0: expected \"%s\" but got \"%s\"\n", expected, r[9]);
- return -1;
- }
- }
- if (r[10] != NULL) {
- fprintf (stderr, "test_tail_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_n_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head_n") == NULL;
- str = getenv ("SKIP_TEST_HEAD_N_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_n_0 (void)
-{
- if (test_head_n_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_n_0");
- return 0;
- }
-
- /* InitBasicFS for test_head_n_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head_n (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head_n (g, 3, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_head_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "0abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_head_n_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_head_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "1abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_head_n_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_head_n_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "2abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_head_n_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_head_n_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_n_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head_n") == NULL;
- str = getenv ("SKIP_TEST_HEAD_N_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_n_1 (void)
-{
- if (test_head_n_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_n_1");
- return 0;
- }
-
- /* InitBasicFS for test_head_n_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head_n (1) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head_n (g, -9997, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_head_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "0abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_head_n_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_head_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "1abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_head_n_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_head_n_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "2abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_head_n_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_head_n_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_n_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head_n") == NULL;
- str = getenv ("SKIP_TEST_HEAD_N_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD_N");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_n_2 (void)
-{
- if (test_head_n_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_n_2");
- return 0;
- }
-
- /* InitBasicFS for test_head_n_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head_n (2) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head_n (g, 0, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_head_n_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_head_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "head") == NULL;
- str = getenv ("SKIP_TEST_HEAD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEAD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_head_0 (void)
-{
- if (test_head_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_head_0");
- return 0;
- }
-
- /* InitBasicFS for test_head_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for head (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_head (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "0abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "1abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "2abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "3abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (!r[4]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "4abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[4], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
- return -1;
- }
- }
- if (!r[5]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "5abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[5], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[5]);
- return -1;
- }
- }
- if (!r[6]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "6abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[6], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[6]);
- return -1;
- }
- }
- if (!r[7]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "7abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[7], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[7]);
- return -1;
- }
- }
- if (!r[8]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "8abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[8], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[8]);
- return -1;
- }
- }
- if (!r[9]) {
- fprintf (stderr, "test_head_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "9abcdefghijklmnopqrstuvwxyz";
- if (strcmp (r[9], expected) != 0) {
- fprintf (stderr, "test_head_0: expected \"%s\" but got \"%s\"\n", expected, r[9]);
- return -1;
- }
- }
- if (r[10] != NULL) {
- fprintf (stderr, "test_head_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_wc_c_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "wc_c") == NULL;
- str = getenv ("SKIP_TEST_WC_C_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WC_C");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_wc_c_0 (void)
-{
- if (test_wc_c_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_wc_c_0");
- return 0;
- }
-
- /* InitBasicFS for test_wc_c_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for wc_c (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/100kallspaces";
- int r;
- suppress_error = 0;
- r = guestfs_wc_c (g, path);
- if (r == -1)
- return -1;
- if (r != 102400) {
- fprintf (stderr, "test_wc_c_0: expected 102400 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_wc_w_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "wc_w") == NULL;
- str = getenv ("SKIP_TEST_WC_W_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WC_W");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_wc_w_0 (void)
-{
- if (test_wc_w_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_wc_w_0");
- return 0;
- }
-
- /* InitBasicFS for test_wc_w_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for wc_w (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- int r;
- suppress_error = 0;
- r = guestfs_wc_w (g, path);
- if (r == -1)
- return -1;
- if (r != 10000) {
- fprintf (stderr, "test_wc_w_0: expected 10000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_wc_l_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "wc_l") == NULL;
- str = getenv ("SKIP_TEST_WC_L_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WC_L");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_wc_l_0 (void)
-{
- if (test_wc_l_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_wc_l_0");
- return 0;
- }
-
- /* InitBasicFS for test_wc_l_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for wc_l (0) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/10klines";
- int r;
- suppress_error = 0;
- r = guestfs_wc_l (g, path);
- if (r == -1)
- return -1;
- if (r != 10000) {
- fprintf (stderr, "test_wc_l_0: expected 10000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdtemp_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdtemp") == NULL;
- str = getenv ("SKIP_TEST_MKDTEMP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDTEMP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdtemp_0 (void)
-{
- if (test_mkdtemp_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdtemp_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkdtemp_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for mkdtemp (0) */
- {
- char path[] = "/tmp";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char template[] = "/tmp/tmpXXXXXX";
- char *r;
- suppress_error = 0;
- r = guestfs_mkdtemp (g, template);
- if (r == NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_scrub_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "scrub_file") == NULL;
- str = getenv ("SKIP_TEST_SCRUB_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SCRUB_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_scrub_file_0 (void)
-{
- if (test_scrub_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_scrub_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_scrub_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for scrub_file (0) */
- {
- char path[] = "/file";
- char content[] = "content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char file[] = "/file";
- int r;
- suppress_error = 0;
- r = guestfs_scrub_file (g, file);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_scrub_device_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "scrub_device") == NULL;
- str = getenv ("SKIP_TEST_SCRUB_DEVICE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SCRUB_DEVICE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_scrub_device_0 (void)
-{
- if (test_scrub_device_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_scrub_device_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_scrub_device_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for scrub_device (0) */
- {
- char device[] = "/dev/sdc";
- int r;
- suppress_error = 0;
- r = guestfs_scrub_device (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_glob_expand_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "glob_expand") == NULL;
- str = getenv ("SKIP_TEST_GLOB_EXPAND_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GLOB_EXPAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_glob_expand_0 (void)
-{
- if (test_glob_expand_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_glob_expand_0");
- return 0;
- }
-
- /* InitBasicFS for test_glob_expand_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for glob_expand (0) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/e";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char pattern[] = "/a/b/c/*";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_glob_expand_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/d";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_glob_expand_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_glob_expand_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/e";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_glob_expand_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_glob_expand_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_glob_expand_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "glob_expand") == NULL;
- str = getenv ("SKIP_TEST_GLOB_EXPAND_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GLOB_EXPAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_glob_expand_1 (void)
-{
- if (test_glob_expand_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_glob_expand_1");
- return 0;
- }
-
- /* InitBasicFS for test_glob_expand_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for glob_expand (1) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/e";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char pattern[] = "/a/*/c/*";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_glob_expand_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/d";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_glob_expand_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_glob_expand_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/a/b/c/e";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_glob_expand_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_glob_expand_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_glob_expand_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "glob_expand") == NULL;
- str = getenv ("SKIP_TEST_GLOB_EXPAND_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GLOB_EXPAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_glob_expand_2 (void)
-{
- if (test_glob_expand_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_glob_expand_2");
- return 0;
- }
-
- /* InitBasicFS for test_glob_expand_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for glob_expand (2) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/e";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char pattern[] = "/a/*/x/*";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_glob_expand (g, pattern);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_glob_expand_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_ntfs_3g_probe_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ntfs_3g_probe") == NULL;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ntfs_3g_probe_0 (void)
-{
- if (test_ntfs_3g_probe_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ntfs_3g_probe_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_ntfs_3g_probe_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputInt for ntfs_3g_probe (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ntfs";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_ntfs_3g_probe (g, 1, device);
- if (r == -1)
- return -1;
- if (r != 0) {
- fprintf (stderr, "test_ntfs_3g_probe_0: expected 0 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_ntfs_3g_probe_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ntfs_3g_probe") == NULL;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ntfs_3g_probe_1 (void)
-{
- if (test_ntfs_3g_probe_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ntfs_3g_probe_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_ntfs_3g_probe_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputInt for ntfs_3g_probe (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_ntfs_3g_probe (g, 1, device);
- if (r == -1)
- return -1;
- if (r != 12) {
- fprintf (stderr, "test_ntfs_3g_probe_1: expected 12 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_sleep_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "sleep") == NULL;
- str = getenv ("SKIP_TEST_SLEEP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SLEEP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_sleep_0 (void)
-{
- if (test_sleep_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_sleep_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_sleep_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for sleep (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_sleep (g, 1);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_find_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "find") == NULL;
- str = getenv ("SKIP_TEST_FIND_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FIND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_find_0 (void)
-{
- if (test_find_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_find_0");
- return 0;
- }
-
- /* InitBasicFS for test_find_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for find (0) */
- {
- char directory[] = "/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_find (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_find_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "lost+found";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_find_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_find_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_find_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "find") == NULL;
- str = getenv ("SKIP_TEST_FIND_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FIND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_find_1 (void)
-{
- if (test_find_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_find_1");
- return 0;
- }
-
- /* InitBasicFS for test_find_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for find (1) */
- {
- char path[] = "/a";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/b";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char directory[] = "/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_find (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "a";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "b";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "b/c";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_find_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "lost+found";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_find_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_find_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "find") == NULL;
- str = getenv ("SKIP_TEST_FIND_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FIND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_find_2 (void)
-{
- if (test_find_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_find_2");
- return 0;
- }
-
- /* InitBasicFS for test_find_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for find (2) */
- {
- char path[] = "/a/b/c";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/a/b/c/d";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char directory[] = "/a/b/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_find (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_find_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "c";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_find_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "c/d";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_find_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvresize_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvresize") == NULL;
- str = getenv ("SKIP_TEST_LVRESIZE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVRESIZE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvresize_0 (void)
-{
- if (test_lvresize_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvresize_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvresize_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutput for lvresize (0) */
- char expected[] = "test content";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 10);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "test content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_lvresize (g, device, 20);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_e2fsck_f (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_resize2fs (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_lvresize_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_zerofree_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "zerofree") == NULL;
- str = getenv ("SKIP_TEST_ZEROFREE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_ZEROFREE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_zerofree_0 (void)
-{
- if (test_zerofree_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_zerofree_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_zerofree_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutput for zerofree (0) */
- char expected[] = "test file";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext3";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "test file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_zerofree (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_zerofree_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_hexdump_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "hexdump") == NULL;
- str = getenv ("SKIP_TEST_HEXDUMP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEXDUMP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_hexdump_0 (void)
-{
- if (test_hexdump_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_hexdump_0");
- return 0;
- }
-
- /* InitBasicFS for test_hexdump_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for hexdump (0) */
- char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
- {
- char path[] = "/new";
- char content[] = "hello\nworld\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 12);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_hexdump (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_hexdump_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "hexdump") == NULL;
- str = getenv ("SKIP_TEST_HEXDUMP_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_HEXDUMP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_hexdump_1 (void)
-{
- if (test_hexdump_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_hexdump_1");
- return 0;
- }
-
- /* InitBasicFS for test_hexdump_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for hexdump (1) */
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/100krandom";
- char *r;
- suppress_error = 0;
- r = guestfs_hexdump (g, path);
- if (r == NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_strings_e_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings_e") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_E_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS_E");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_e_0 (void)
-{
- if (test_strings_e_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_e_0");
- return 0;
- }
-
- /* InitBasicFS for test_strings_e_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for strings_e (0) */
- {
- char path[] = "/new";
- char content[] = "hello\nworld\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char encoding[] = "b";
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_strings_e (g, encoding, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_strings_e_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings_e") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_E_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS_E");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_e_1 (void)
-{
- if (test_strings_e_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_e_1");
- return 0;
- }
-
- printf (" %s skipped (reason: test disabled in generator)\n", "test_strings_e_1");
- return 0;
-}
-
-static int test_strings_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_0 (void)
-{
- if (test_strings_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_0");
- return 0;
- }
-
- /* InitBasicFS for test_strings_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for strings (0) */
- {
- char path[] = "/new";
- char content[] = "hello\nworld\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_strings (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_strings_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "hello";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_strings_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "world";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_strings_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_strings_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "strings") == NULL;
- str = getenv ("SKIP_TEST_STRINGS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STRINGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_strings_1 (void)
-{
- if (test_strings_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_strings_1");
- return 0;
- }
-
- /* InitBasicFS for test_strings_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for strings (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_strings (g, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_strings_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_equal_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "equal") == NULL;
- str = getenv ("SKIP_TEST_EQUAL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EQUAL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_equal_0 (void)
-{
- if (test_equal_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_equal_0");
- return 0;
- }
-
- /* InitBasicFS for test_equal_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for equal (0) */
- {
- char path[] = "/file1";
- char content[] = "contents of a file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/file1";
- char dest[] = "/file2";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char file1[] = "/file1";
- char file2[] = "/file2";
- int r;
- suppress_error = 0;
- r = guestfs_equal (g, file1, file2);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_equal_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_equal_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "equal") == NULL;
- str = getenv ("SKIP_TEST_EQUAL_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EQUAL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_equal_1 (void)
-{
- if (test_equal_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_equal_1");
- return 0;
- }
-
- /* InitBasicFS for test_equal_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for equal (1) */
- {
- char path[] = "/file1";
- char content[] = "contents of a file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/file2";
- char content[] = "contents of another file";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char file1[] = "/file1";
- char file2[] = "/file2";
- int r;
- suppress_error = 0;
- r = guestfs_equal (g, file1, file2);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_equal_1: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_equal_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "equal") == NULL;
- str = getenv ("SKIP_TEST_EQUAL_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EQUAL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_equal_2 (void)
-{
- if (test_equal_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_equal_2");
- return 0;
- }
-
- /* InitBasicFS for test_equal_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for equal (2) */
- {
- char file1[] = "/file1";
- char file2[] = "/file2";
- int r;
- suppress_error = 1;
- r = guestfs_equal (g, file1, file2);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_ping_daemon_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ping_daemon") == NULL;
- str = getenv ("SKIP_TEST_PING_DAEMON_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PING_DAEMON");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ping_daemon_0 (void)
-{
- if (test_ping_daemon_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ping_daemon_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_ping_daemon_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for ping_daemon (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_ping_daemon (g);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_dmesg_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "dmesg") == NULL;
- str = getenv ("SKIP_TEST_DMESG_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DMESG");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_dmesg_0 (void)
-{
- if (test_dmesg_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_dmesg_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_dmesg_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for dmesg (0) */
- {
- char *r;
- suppress_error = 0;
- r = guestfs_dmesg (g);
- if (r == NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_drop_caches_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "drop_caches") == NULL;
- str = getenv ("SKIP_TEST_DROP_CACHES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DROP_CACHES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_drop_caches_0 (void)
-{
- if (test_drop_caches_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_drop_caches_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_drop_caches_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for drop_caches (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_drop_caches (g, 3);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mv_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mv") == NULL;
- str = getenv ("SKIP_TEST_MV_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MV");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mv_0 (void)
-{
- if (test_mv_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mv_0");
- return 0;
- }
-
- /* InitBasicFS for test_mv_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for mv (0) */
- char expected[] = "file content";
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mv (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mv_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mv") == NULL;
- str = getenv ("SKIP_TEST_MV_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MV");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mv_1 (void)
-{
- if (test_mv_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mv_1");
- return 0;
- }
-
- /* InitBasicFS for test_mv_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for mv (1) */
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mv (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/old";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_mv_1: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_cp_a_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp_a") == NULL;
- str = getenv ("SKIP_TEST_CP_A_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP_A");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_a_0 (void)
-{
- if (test_cp_a_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_a_0");
- return 0;
- }
-
- /* InitBasicFS for test_cp_a_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cp_a (0) */
- char expected[] = "file content";
- {
- char path[] = "/olddir";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newdir";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/olddir/file";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/olddir";
- char dest[] = "/newdir";
- int r;
- suppress_error = 0;
- r = guestfs_cp_a (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newdir/olddir/file";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_cp_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp") == NULL;
- str = getenv ("SKIP_TEST_CP_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_0 (void)
-{
- if (test_cp_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_0");
- return 0;
- }
-
- /* InitBasicFS for test_cp_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cp (0) */
- char expected[] = "file content";
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_cp_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp") == NULL;
- str = getenv ("SKIP_TEST_CP_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_1 (void)
-{
- if (test_cp_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_1");
- return 0;
- }
-
- /* InitBasicFS for test_cp_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for cp (1) */
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/old";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_cp_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_cp_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cp") == NULL;
- str = getenv ("SKIP_TEST_CP_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CP");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cp_2 (void)
-{
- if (test_cp_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cp_2");
- return 0;
- }
-
- /* InitBasicFS for test_cp_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cp (2) */
- char expected[] = "file content";
- {
- char path[] = "/old";
- char content[] = "file content";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/dir";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char src[] = "/old";
- char dest[] = "/dir/new";
- int r;
- suppress_error = 0;
- r = guestfs_cp (g, src, dest);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/dir/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_grub_install_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "grub_install") == NULL;
- str = getenv ("SKIP_TEST_GRUB_INSTALL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_GRUB_INSTALL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_grub_install_0 (void)
-{
- if (test_grub_install_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_grub_install_0");
- return 0;
- }
-
- printf (" %s skipped (reason: test disabled in generator)\n", "test_grub_install_0");
- return 0;
-}
-
-static int test_zero_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "zero") == NULL;
- str = getenv ("SKIP_TEST_ZERO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_ZERO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_zero_0 (void)
-{
- if (test_zero_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_zero_0");
- return 0;
- }
-
- /* InitBasicFS for test_zero_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for zero (0) */
- char expected[] = "data";
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_zero (g, device);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_file (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_fsck_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "fsck") == NULL;
- str = getenv ("SKIP_TEST_FSCK_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FSCK");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_fsck_0 (void)
-{
- if (test_fsck_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_fsck_0");
- return 0;
- }
-
- /* InitBasicFS for test_fsck_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for fsck (0) */
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_fsck (g, fstype, device);
- if (r == -1)
- return -1;
- if (r != 0) {
- fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_fsck_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "fsck") == NULL;
- str = getenv ("SKIP_TEST_FSCK_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FSCK");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_fsck_1 (void)
-{
- if (test_fsck_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_fsck_1");
- return 0;
- }
-
- /* InitBasicFS for test_fsck_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputInt for fsck (1) */
- {
- char pathordevice[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_zero (g, device);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_fsck (g, fstype, device);
- if (r == -1)
- return -1;
- if (r != 8) {
- fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_set_e2uuid_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_0 (void)
-{
- if (test_set_e2uuid_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_0");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for set_e2uuid (0) */
- char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
- {
- char device[] = "/dev/sda1";
- char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_get_e2uuid (g, device);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_set_e2uuid_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_1 (void)
-{
- if (test_set_e2uuid_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_1");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for set_e2uuid (1) */
- char expected[] = "";
- {
- char device[] = "/dev/sda1";
- char uuid[] = "clear";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_get_e2uuid (g, device);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_set_e2uuid_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_2 (void)
-{
- if (test_set_e2uuid_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_2");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for set_e2uuid (2) */
- {
- char device[] = "/dev/sda1";
- char uuid[] = "random";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_set_e2uuid_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2uuid") == NULL;
- str = getenv ("SKIP_TEST_SET_E2UUID_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2UUID");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2uuid_3 (void)
-{
- if (test_set_e2uuid_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2uuid_3");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2uuid_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for set_e2uuid (3) */
- {
- char device[] = "/dev/sda1";
- char uuid[] = "time";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2uuid (g, device, uuid);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_set_e2label_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "set_e2label") == NULL;
- str = getenv ("SKIP_TEST_SET_E2LABEL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SET_E2LABEL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_set_e2label_0 (void)
-{
- if (test_set_e2label_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_set_e2label_0");
- return 0;
- }
-
- /* InitBasicFS for test_set_e2label_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for set_e2label (0) */
- char expected[] = "testlabel";
- {
- char device[] = "/dev/sda1";
- char label[] = "testlabel";
- int r;
- suppress_error = 0;
- r = guestfs_set_e2label (g, device, label);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char *r;
- suppress_error = 0;
- r = guestfs_get_e2label (g, device);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_pvremove_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvremove") == NULL;
- str = getenv ("SKIP_TEST_PVREMOVE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvremove_0 (void)
-{
- if (test_pvremove_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvremove_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvremove_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for pvremove (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvremove_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvremove") == NULL;
- str = getenv ("SKIP_TEST_PVREMOVE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvremove_1 (void)
-{
- if (test_pvremove_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvremove_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvremove_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for pvremove (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvremove_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvremove") == NULL;
- str = getenv ("SKIP_TEST_PVREMOVE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvremove_2 (void)
-{
- if (test_pvremove_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvremove_2");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvremove_2 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for pvremove (2) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgremove_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgremove") == NULL;
- str = getenv ("SKIP_TEST_VGREMOVE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgremove_0 (void)
-{
- if (test_vgremove_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgremove_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgremove_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for vgremove (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgremove_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgremove") == NULL;
- str = getenv ("SKIP_TEST_VGREMOVE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgremove_1 (void)
-{
- if (test_vgremove_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgremove_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgremove_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for vgremove (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char vgname[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_vgremove (g, vgname);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvremove_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvremove") == NULL;
- str = getenv ("SKIP_TEST_LVREMOVE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvremove_0 (void)
-{
- if (test_lvremove_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvremove_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvremove_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for lvremove (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV1";
- int r;
- suppress_error = 0;
- r = guestfs_lvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvremove_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG/LV2";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvremove_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvremove") == NULL;
- str = getenv ("SKIP_TEST_LVREMOVE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvremove_1 (void)
-{
- if (test_lvremove_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvremove_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvremove_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for lvremove (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvremove_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvremove") == NULL;
- str = getenv ("SKIP_TEST_LVREMOVE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVREMOVE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvremove_2 (void)
-{
- if (test_lvremove_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvremove_2");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvremove_2 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for lvremove (2) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvremove (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvremove_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_mount_ro_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mount_ro") == NULL;
- str = getenv ("SKIP_TEST_MOUNT_RO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNT_RO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mount_ro_0 (void)
-{
- if (test_mount_ro_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mount_ro_0");
- return 0;
- }
-
- /* InitBasicFS for test_mount_ro_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for mount_ro (0) */
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_ro (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_touch (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mount_ro_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mount_ro") == NULL;
- str = getenv ("SKIP_TEST_MOUNT_RO_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNT_RO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mount_ro_1 (void)
-{
- if (test_mount_ro_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mount_ro_1");
- return 0;
- }
-
- /* InitBasicFS for test_mount_ro_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for mount_ro (1) */
- char expected[] = "data";
- {
- char path[] = "/new";
- char content[] = "data";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_ro (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_tgz_in_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tgz_in") == NULL;
- str = getenv ("SKIP_TEST_TGZ_IN_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TGZ_IN");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tgz_in_0 (void)
-{
- if (test_tgz_in_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tgz_in_0");
- return 0;
- }
-
- /* InitBasicFS for test_tgz_in_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for tgz_in (0) */
- char expected[] = "hello\n";
- {
- char directory[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_tgz_in (g, "../images/helloworld.tar.gz", directory);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/hello";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_tar_in_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "tar_in") == NULL;
- str = getenv ("SKIP_TEST_TAR_IN_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TAR_IN");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_tar_in_0 (void)
-{
- if (test_tar_in_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_tar_in_0");
- return 0;
- }
-
- /* InitBasicFS for test_tar_in_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for tar_in (0) */
- char expected[] = "hello\n";
- {
- char directory[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_tar_in (g, "../images/helloworld.tar", directory);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/hello";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_0 (void)
-{
- if (test_checksum_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_0");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (0) */
- char expected[] = "935282863";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "crc";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_1 (void)
-{
- if (test_checksum_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_1");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for checksum (1) */
- {
- char csumtype[] = "crc";
- char path[] = "/new";
- char *r;
- suppress_error = 1;
- r = guestfs_checksum (g, csumtype, path);
- if (r != NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_2 (void)
-{
- if (test_checksum_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_2");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (2) */
- char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_3 (void)
-{
- if (test_checksum_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_3");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (3) */
- char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha1";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_4 (void)
-{
- if (test_checksum_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_4");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (4) */
- char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha224";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_5 (void)
-{
- if (test_checksum_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_5");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (5) */
- char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha256";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_6_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_6");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_6 (void)
-{
- if (test_checksum_6_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_6");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_6: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (6) */
- char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha384";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_7_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_7");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_7 (void)
-{
- if (test_checksum_7_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_7");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_7: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (7) */
- char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
- {
- char path[] = "/new";
- char content[] = "test\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "sha512";
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_checksum_8_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "checksum") == NULL;
- str = getenv ("SKIP_TEST_CHECKSUM_8");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CHECKSUM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_checksum_8 (void)
-{
- if (test_checksum_8_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_checksum_8");
- return 0;
- }
-
- /* InitBasicFS for test_checksum_8: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for checksum (8) */
- char expected[] = "46d6ca27ee07cdc6fa99c2e138cc522c";
- {
- char options[] = "ro";
- char vfstype[] = "squashfs";
- char device[] = "/dev/sdd";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/known-3";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_checksum_8: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_download_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "download") == NULL;
- str = getenv ("SKIP_TEST_DOWNLOAD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_DOWNLOAD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_download_0 (void)
-{
- if (test_download_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_download_0");
- return 0;
- }
-
- /* InitBasicFS for test_download_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for download (0) */
- char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
- {
- char remotefilename[] = "/COPYING.LIB";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char remotefilename[] = "/COPYING.LIB";
- int r;
- suppress_error = 0;
- r = guestfs_download (g, remotefilename, "testdownload.tmp");
- if (r == -1)
- return -1;
- }
- {
- char remotefilename[] = "/upload";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "testdownload.tmp", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/upload";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_upload_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "upload") == NULL;
- str = getenv ("SKIP_TEST_UPLOAD_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UPLOAD");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_upload_0 (void)
-{
- if (test_upload_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_upload_0");
- return 0;
- }
-
- /* InitBasicFS for test_upload_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for upload (0) */
- char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
- {
- char remotefilename[] = "/COPYING.LIB";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char csumtype[] = "md5";
- char path[] = "/COPYING.LIB";
- char *r;
- suppress_error = 0;
- r = guestfs_checksum (g, csumtype, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_blockdev_rereadpt_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_rereadpt") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_rereadpt_0 (void)
-{
- if (test_blockdev_rereadpt_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_rereadpt_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_rereadpt_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for blockdev_rereadpt (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_rereadpt (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_blockdev_flushbufs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_flushbufs") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_flushbufs_0 (void)
-{
- if (test_blockdev_flushbufs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_flushbufs_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_flushbufs_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for blockdev_flushbufs (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_flushbufs (g, device);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_blockdev_getsize64_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getsize64") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getsize64_0 (void)
-{
- if (test_blockdev_getsize64_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getsize64_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getsize64_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputInt for blockdev_getsize64 (0) */
- {
- char device[] = "/dev/sda";
- int64_t r;
- suppress_error = 0;
- r = guestfs_blockdev_getsize64 (g, device);
- if (r == -1)
- return -1;
- if (r != 524288000) {
- fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getsz_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getsz") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getsz_0 (void)
-{
- if (test_blockdev_getsz_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getsz_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getsz_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputInt for blockdev_getsz (0) */
- {
- char device[] = "/dev/sda";
- int64_t r;
- suppress_error = 0;
- r = guestfs_blockdev_getsz (g, device);
- if (r == -1)
- return -1;
- if (r != 1024000) {
- fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getbsz_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getbsz") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getbsz_0 (void)
-{
- if (test_blockdev_getbsz_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getbsz_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getbsz_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputInt for blockdev_getbsz (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getbsz (g, device);
- if (r == -1)
- return -1;
- if (r != 4096) {
- fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getss_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getss") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETSS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getss_0 (void)
-{
- if (test_blockdev_getss_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getss_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getss_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputInt for blockdev_getss (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getss (g, device);
- if (r == -1)
- return -1;
- if (r != 512) {
- fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_getro_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_getro") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETRO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_GETRO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_getro_0 (void)
-{
- if (test_blockdev_getro_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_getro_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_getro_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputTrue for blockdev_getro (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setro (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getro (g, device);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_setrw_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_setrw") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRW_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRW");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_setrw_0 (void)
-{
- if (test_blockdev_setrw_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_setrw_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_setrw_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputFalse for blockdev_setrw (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getro (g, device);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_blockdev_setro_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "blockdev_setro") == NULL;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRO_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_BLOCKDEV_SETRO");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_blockdev_setro_0 (void)
-{
- if (test_blockdev_setro_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_blockdev_setro_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_blockdev_setro_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputTrue for blockdev_setro (0) */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setro (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_getro (g, device);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_statvfs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "statvfs") == NULL;
- str = getenv ("SKIP_TEST_STATVFS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STATVFS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_statvfs_0 (void)
-{
- if (test_statvfs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_statvfs_0");
- return 0;
- }
-
- /* InitBasicFS for test_statvfs_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for statvfs (0) */
- {
- char path[] = "/";
- struct guestfs_statvfs *r;
- suppress_error = 0;
- r = guestfs_statvfs (g, path);
- if (r == NULL)
- return -1;
- if (r->namemax != 255) {
- fprintf (stderr, "test_statvfs_0: namemax was %d, expected 255\n",
- (int) r->namemax);
- 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;
-}
-
-static int test_lstat_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lstat") == NULL;
- str = getenv ("SKIP_TEST_LSTAT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LSTAT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lstat_0 (void)
-{
- if (test_lstat_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lstat_0");
- return 0;
- }
-
- /* InitBasicFS for test_lstat_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for lstat (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_lstat (g, path);
- 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_stat_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "stat") == NULL;
- str = getenv ("SKIP_TEST_STAT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_STAT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_stat_0 (void)
-{
- if (test_stat_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_stat_0");
- return 0;
- }
-
- /* InitBasicFS for test_stat_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputStruct for stat (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- struct guestfs_stat *r;
- suppress_error = 0;
- r = guestfs_stat (g, path);
- 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_command_lines_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_0 (void)
-{
- if (test_command_lines_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_0");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (0) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "1";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_command_lines_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_1 (void)
-{
- if (test_command_lines_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_1");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (1) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "2";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result2";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_command_lines_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_2 (void)
-{
- if (test_command_lines_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_2");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (2) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "3";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_2: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result3";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_2: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_3 (void)
-{
- if (test_command_lines_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_3");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (3) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "4";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_3: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_3: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result4";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_3: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_4 (void)
-{
- if (test_command_lines_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_4");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (4) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "5";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_4: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_4: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result5";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_command_lines_4: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_command_lines_4: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_5 (void)
-{
- if (test_command_lines_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_5");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (5) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "6";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result6";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_command_lines_5: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_command_lines_5: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_6_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_6");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_6 (void)
-{
- if (test_command_lines_6_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_6");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_6: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (6) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "7";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_command_lines_6: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_7_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_7");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_7 (void)
-{
- if (test_command_lines_7_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_7");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_7: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (7) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "8";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_7: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_7: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_command_lines_7: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_8_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_8");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_8 (void)
-{
- if (test_command_lines_8_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_8");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_8: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (8) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "9";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_8: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_8: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_8: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_9_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_9");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_9 (void)
-{
- if (test_command_lines_9_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_9");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_9: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (9) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "10";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_9: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result10-1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_9: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result10-2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_9: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_lines_10_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command_lines") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_LINES_10");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_lines_10 (void)
-{
- if (test_command_lines_10_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_lines_10");
- return 0;
- }
-
- /* InitBasicFS for test_command_lines_10: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for command_lines (10) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "11";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_command_lines (g, arguments);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_command_lines_10: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result11-1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_command_lines_10: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "Result11-2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_command_lines_10: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_command_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_0 (void)
-{
- if (test_command_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_0");
- return 0;
- }
-
- /* InitBasicFS for test_command_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (0) */
- char expected[] = "Result1";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "1";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_1 (void)
-{
- if (test_command_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_1");
- return 0;
- }
-
- /* InitBasicFS for test_command_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (1) */
- char expected[] = "Result2\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "2";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_2 (void)
-{
- if (test_command_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_2");
- return 0;
- }
-
- /* InitBasicFS for test_command_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (2) */
- char expected[] = "\nResult3";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "3";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_3 (void)
-{
- if (test_command_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_3");
- return 0;
- }
-
- /* InitBasicFS for test_command_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (3) */
- char expected[] = "\nResult4\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "4";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_3: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_4 (void)
-{
- if (test_command_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_4");
- return 0;
- }
-
- /* InitBasicFS for test_command_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (4) */
- char expected[] = "\nResult5\n\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "5";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_4: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_5 (void)
-{
- if (test_command_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_5");
- return 0;
- }
-
- /* InitBasicFS for test_command_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (5) */
- char expected[] = "\n\nResult6\n\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "6";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_5: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_6_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_6");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_6 (void)
-{
- if (test_command_6_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_6");
- return 0;
- }
-
- /* InitBasicFS for test_command_6: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (6) */
- char expected[] = "";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "7";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_6: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_7_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_7");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_7 (void)
-{
- if (test_command_7_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_7");
- return 0;
- }
-
- /* InitBasicFS for test_command_7: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (7) */
- char expected[] = "\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "8";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_7: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_8_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_8");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_8 (void)
-{
- if (test_command_8_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_8");
- return 0;
- }
-
- /* InitBasicFS for test_command_8: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (8) */
- char expected[] = "\n\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "9";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_8: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_9_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_9");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_9 (void)
-{
- if (test_command_9_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_9");
- return 0;
- }
-
- /* InitBasicFS for test_command_9: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (9) */
- char expected[] = "Result10-1\nResult10-2\n";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "10";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_9: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_10_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_10");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_10 (void)
-{
- if (test_command_10_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_10");
- return 0;
- }
-
- /* InitBasicFS for test_command_10: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for command (10) */
- char expected[] = "Result11-1\nResult11-2";
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char arguments_1[] = "11";
- char *arguments[] = {
- arguments_0,
- arguments_1,
- NULL
- };
- char *r;
- suppress_error = 0;
- r = guestfs_command (g, arguments);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_command_10: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_command_11_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "command") == NULL;
- str = getenv ("SKIP_TEST_COMMAND_11");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_COMMAND");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_command_11 (void)
-{
- if (test_command_11_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_command_11");
- return 0;
- }
-
- /* InitBasicFS for test_command_11: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for command (11) */
- {
- char remotefilename[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_upload (g, "test-command", remotefilename);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/test-command";
- int r;
- suppress_error = 0;
- r = guestfs_chmod (g, 493, path);
- if (r == -1)
- return -1;
- }
- {
- char arguments_0[] = "/test-command";
- char *arguments[] = {
- arguments_0,
- NULL
- };
- char *r;
- suppress_error = 1;
- r = guestfs_command (g, arguments);
- if (r != NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "file") == NULL;
- str = getenv ("SKIP_TEST_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_file_0 (void)
-{
- if (test_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for file (0) */
- char expected[] = "empty";
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_file (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_file_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "file") == NULL;
- str = getenv ("SKIP_TEST_FILE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_file_1 (void)
-{
- if (test_file_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_file_1");
- return 0;
- }
-
- /* InitBasicFS for test_file_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for file (1) */
- char expected[] = "ASCII text";
- {
- char path[] = "/new";
- char content[] = "some content\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_file (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_file_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "file") == NULL;
- str = getenv ("SKIP_TEST_FILE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_file_2 (void)
-{
- if (test_file_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_file_2");
- return 0;
- }
-
- /* InitBasicFS for test_file_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for file (2) */
- {
- char path[] = "/nofile";
- char *r;
- suppress_error = 1;
- r = guestfs_file (g, path);
- if (r != NULL)
- return -1;
- free (r);
- }
- return 0;
-}
-
-static int test_umount_all_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount_all") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_ALL_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT_ALL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_all_0 (void)
-{
- if (test_umount_all_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_all_0");
- return 0;
- }
-
- /* InitBasicFS for test_umount_all_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for umount_all (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_umount_all_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount_all") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_ALL_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT_ALL");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_all_1 (void)
-{
- if (test_umount_all_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_all_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_umount_all_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for umount_all (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/mp1";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- char mountpoint[] = "/mp1";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/mp1/mp2";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- char mountpoint[] = "/mp1/mp2";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/mp1/mp2/mp3";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- int r;
- suppress_error = 0;
- r = guestfs_umount_all (g);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_mounts_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mounts") == NULL;
- str = getenv ("SKIP_TEST_MOUNTS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNTS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mounts_0 (void)
-{
- if (test_mounts_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mounts_0");
- return 0;
- }
-
- /* InitBasicFS for test_mounts_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for mounts (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_mounts_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_umount_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_0 (void)
-{
- if (test_umount_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_umount_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for umount (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_umount_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_umount_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_umount_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "umount") == NULL;
- str = getenv ("SKIP_TEST_UMOUNT_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_UMOUNT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_umount_1 (void)
-{
- if (test_umount_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_umount_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_umount_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for umount (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char pathordevice[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_umount (g, pathordevice);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_mounts (g);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_umount_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_0 (void)
-{
- if (test_write_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (0) */
- char expected[] = "new file contents";
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_1 (void)
-{
- if (test_write_file_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_1");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (1) */
- char expected[] = "\nnew file contents\n";
- {
- char path[] = "/new";
- char content[] = "\nnew file contents\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_2 (void)
-{
- if (test_write_file_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_2");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (2) */
- char expected[] = "\n\n";
- {
- char path[] = "/new";
- char content[] = "\n\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_3 (void)
-{
- if (test_write_file_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_3");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (3) */
- char expected[] = "";
- {
- char path[] = "/new";
- char content[] = "";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_4 (void)
-{
- if (test_write_file_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_4");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (4) */
- char expected[] = "\n\n\n";
- {
- char path[] = "/new";
- char content[] = "\n\n\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_write_file_5_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "write_file") == NULL;
- str = getenv ("SKIP_TEST_WRITE_FILE_5");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_WRITE_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_write_file_5 (void)
-{
- if (test_write_file_5_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_write_file_5");
- return 0;
- }
-
- /* InitBasicFS for test_write_file_5: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for write_file (5) */
- char expected[] = "\n";
- {
- char path[] = "/new";
- char content[] = "\n";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_mkfs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkfs") == NULL;
- str = getenv ("SKIP_TEST_MKFS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKFS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkfs_0 (void)
-{
- if (test_mkfs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkfs_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mkfs_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutput for mkfs (0) */
- char expected[] = "new file contents";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_lvcreate_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvcreate") == NULL;
- str = getenv ("SKIP_TEST_LVCREATE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVCREATE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvcreate_0 (void)
-{
- if (test_lvcreate_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvcreate_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvcreate_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for lvcreate (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV3";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV4";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV5";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV3";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV4";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (!r[4]) {
- fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV5";
- if (strcmp (r[4], expected) != 0) {
- fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
- return -1;
- }
- }
- if (r[5] != NULL) {
- fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgcreate_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgcreate") == NULL;
- str = getenv ("SKIP_TEST_VGCREATE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGCREATE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgcreate_0 (void)
-{
- if (test_vgcreate_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgcreate_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgcreate_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for vgcreate (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvcreate_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvcreate") == NULL;
- str = getenv ("SKIP_TEST_PVCREATE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVCREATE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvcreate_0 (void)
-{
- if (test_pvcreate_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvcreate_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvcreate_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for pvcreate (0) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda2";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda3";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_is_dir_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_dir") == NULL;
- str = getenv ("SKIP_TEST_IS_DIR_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_DIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_dir_0 (void)
-{
- if (test_is_dir_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_dir_0");
- return 0;
- }
-
- /* InitBasicFS for test_is_dir_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for is_dir (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_is_dir_0: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_is_dir_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_dir") == NULL;
- str = getenv ("SKIP_TEST_IS_DIR_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_DIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_dir_1 (void)
-{
- if (test_is_dir_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_dir_1");
- return 0;
- }
-
- /* InitBasicFS for test_is_dir_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for is_dir (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_is_dir_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_is_file_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_file") == NULL;
- str = getenv ("SKIP_TEST_IS_FILE_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_file_0 (void)
-{
- if (test_is_file_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_file_0");
- return 0;
- }
-
- /* InitBasicFS for test_is_file_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for is_file (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_is_file_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_is_file_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "is_file") == NULL;
- str = getenv ("SKIP_TEST_IS_FILE_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_IS_FILE");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_is_file_1 (void)
-{
- if (test_is_file_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_is_file_1");
- return 0;
- }
-
- /* InitBasicFS for test_is_file_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for is_file (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_file (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_is_file_1: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_exists_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "exists") == NULL;
- str = getenv ("SKIP_TEST_EXISTS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EXISTS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_exists_0 (void)
-{
- if (test_exists_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_exists_0");
- return 0;
- }
-
- /* InitBasicFS for test_exists_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for exists (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_exists_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_exists_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "exists") == NULL;
- str = getenv ("SKIP_TEST_EXISTS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_EXISTS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_exists_1 (void)
-{
- if (test_exists_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_exists_1");
- return 0;
- }
-
- /* InitBasicFS for test_exists_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for exists (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_exists_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_0 (void)
-{
- if (test_mkdir_p_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir_p (0) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_1 (void)
-{
- if (test_mkdir_p_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_1");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir_p (1) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_2 (void)
-{
- if (test_mkdir_p_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_2");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir_p (2) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_p_3_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_3");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_3 (void)
-{
- if (test_mkdir_p_3_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_3");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_3: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for mkdir_p (3) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir_p (g, path);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkdir_p_4_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir_p") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_P_4");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR_P");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_p_4 (void)
-{
- if (test_mkdir_p_4_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_p_4");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_p_4: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for mkdir_p (4) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_mkdir_p (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mkdir_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_0 (void)
-{
- if (test_mkdir_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_0");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for mkdir (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_is_dir (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_mkdir_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_mkdir_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mkdir") == NULL;
- str = getenv ("SKIP_TEST_MKDIR_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MKDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mkdir_1 (void)
-{
- if (test_mkdir_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mkdir_1");
- return 0;
- }
-
- /* InitBasicFS for test_mkdir_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for mkdir (1) */
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 1;
- r = guestfs_mkdir (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_rf_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm_rf") == NULL;
- str = getenv ("SKIP_TEST_RM_RF_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM_RF");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_rf_0 (void)
-{
- if (test_rm_rf_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_rf_0");
- return 0;
- }
-
- /* InitBasicFS for test_rm_rf_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputFalse for rm_rf (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new/foo/bar";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_rm_rf (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (r) {
- fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_rmdir_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rmdir") == NULL;
- str = getenv ("SKIP_TEST_RMDIR_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RMDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rmdir_0 (void)
-{
- if (test_rmdir_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rmdir_0");
- return 0;
- }
-
- /* InitBasicFS for test_rmdir_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for rmdir (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_rmdir (g, path);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rmdir_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rmdir") == NULL;
- str = getenv ("SKIP_TEST_RMDIR_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RMDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rmdir_1 (void)
-{
- if (test_rmdir_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rmdir_1");
- return 0;
- }
-
- /* InitBasicFS for test_rmdir_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rmdir (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rmdir (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rmdir_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rmdir") == NULL;
- str = getenv ("SKIP_TEST_RMDIR_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RMDIR");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rmdir_2 (void)
-{
- if (test_rmdir_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rmdir_2");
- return 0;
- }
-
- /* InitBasicFS for test_rmdir_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rmdir (2) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rmdir (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm") == NULL;
- str = getenv ("SKIP_TEST_RM_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_0 (void)
-{
- if (test_rm_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_0");
- return 0;
- }
-
- /* InitBasicFS for test_rm_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestRun for rm (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_rm (g, path);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm") == NULL;
- str = getenv ("SKIP_TEST_RM_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_1 (void)
-{
- if (test_rm_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_1");
- return 0;
- }
-
- /* InitBasicFS for test_rm_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rm (1) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rm (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_rm_2_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "rm") == NULL;
- str = getenv ("SKIP_TEST_RM_2");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_RM");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_rm_2 (void)
-{
- if (test_rm_2_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_rm_2");
- return 0;
- }
-
- /* InitBasicFS for test_rm_2: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestLastFail for rm (2) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_mkdir (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 1;
- r = guestfs_rm (g, path);
- if (r != -1)
- return -1;
- }
- return 0;
-}
-
-static int test_read_lines_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "read_lines") == NULL;
- str = getenv ("SKIP_TEST_READ_LINES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_READ_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_read_lines_0 (void)
-{
- if (test_read_lines_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_read_lines_0");
- return 0;
- }
-
- /* InitBasicFS for test_read_lines_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for read_lines (0) */
- {
- char path[] = "/new";
- char content[] = "line1\r\nline2\nline3";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_read_lines (g, path);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_read_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "line1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_read_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "line2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_read_lines_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "line3";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_read_lines_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "read_lines") == NULL;
- str = getenv ("SKIP_TEST_READ_LINES_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_READ_LINES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_read_lines_1 (void)
-{
- if (test_read_lines_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_read_lines_1");
- return 0;
- }
-
- /* InitBasicFS for test_read_lines_1: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for read_lines (1) */
- {
- char path[] = "/new";
- char content[] = "";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_read_lines (g, path);
- if (r == NULL)
- return -1;
- if (r[0] != NULL) {
- fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvs") == NULL;
- str = getenv ("SKIP_TEST_LVS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvs_0 (void)
-{
- if (test_lvs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvs_0");
- return 0;
- }
-
- /* InitBasicFSonLVM for test_lvs_0: create ext2 on /dev/VG/LV */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 8);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for lvs (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvs_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG/LV";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_lvs_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "lvs") == NULL;
- str = getenv ("SKIP_TEST_LVS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_lvs_1 (void)
-{
- if (test_lvs_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_lvs_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_lvs_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for lvs (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV1";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV2";
- char volgroup[] = "VG1";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV3";
- char volgroup[] = "VG2";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 50);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_lvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_lvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_lvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG1/LV2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_lvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/VG2/LV3";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgs") == NULL;
- str = getenv ("SKIP_TEST_VGS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgs_0 (void)
-{
- if (test_vgs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgs_0");
- return 0;
- }
-
- /* InitBasicFSonLVM for test_vgs_0: create ext2 on /dev/VG/LV */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 8);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for vgs (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_vgs_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_vgs_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "vgs") == NULL;
- str = getenv ("SKIP_TEST_VGS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_VGS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_vgs_1 (void)
-{
- if (test_vgs_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_vgs_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_vgs_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputList for vgs (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG1";
- char physvols_0[] = "/dev/sda1";
- char physvols_1[] = "/dev/sda2";
- char *physvols[] = {
- physvols_0,
- physvols_1,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG2";
- char physvols_0[] = "/dev/sda3";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_vgs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_vgs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG1";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_vgs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "VG2";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (r[2] != NULL) {
- fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvs_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvs") == NULL;
- str = getenv ("SKIP_TEST_PVS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvs_0 (void)
-{
- if (test_pvs_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvs_0");
- return 0;
- }
-
- /* InitBasicFSonLVM for test_pvs_0: create ext2 on /dev/VG/LV */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char volgroup[] = "VG";
- char physvols_0[] = "/dev/sda1";
- char *physvols[] = {
- physvols_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_vgcreate (g, volgroup, physvols);
- if (r == -1)
- return -1;
- }
- {
- char logvol[] = "LV";
- char volgroup[] = "VG";
- int r;
- suppress_error = 0;
- r = guestfs_lvcreate (g, logvol, volgroup, 8);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/VG/LV";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/VG/LV";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for pvs (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_pvs_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_pvs_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "pvs") == NULL;
- str = getenv ("SKIP_TEST_PVS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_PVS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_pvs_1 (void)
-{
- if (test_pvs_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_pvs_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_pvs_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for pvs (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda2";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda3";
- int r;
- suppress_error = 0;
- r = guestfs_pvcreate (g, device);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_pvs (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_pvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_pvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda2";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_pvs_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda3";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_list_partitions_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "list_partitions") == NULL;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_list_partitions_0 (void)
-{
- if (test_list_partitions_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_list_partitions_0");
- return 0;
- }
-
- /* InitBasicFS for test_list_partitions_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputListOfDevices for list_partitions (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_list_partitions (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (r[1] != NULL) {
- fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_list_partitions_1_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "list_partitions") == NULL;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS_1");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LIST_PARTITIONS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_list_partitions_1 (void)
-{
- if (test_list_partitions_1_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_list_partitions_1");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_list_partitions_1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for list_partitions (1) */
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",200";
- char lines_1[] = ",400";
- char lines_2[] = ",";
- char *lines[] = {
- lines_0,
- lines_1,
- lines_2,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_list_partitions (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda1";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda2";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda3";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (r[3] != NULL) {
- fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_list_devices_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "list_devices") == NULL;
- str = getenv ("SKIP_TEST_LIST_DEVICES_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LIST_DEVICES");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_list_devices_0 (void)
-{
- if (test_list_devices_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_list_devices_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_list_devices_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutputListOfDevices for list_devices (0) */
- {
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_list_devices (g);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sda";
- r[0][5] = 's';
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sdb";
- r[1][5] = 's';
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sdc";
- r[2][5] = 's';
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_list_devices_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "/dev/sdd";
- r[3][5] = 's';
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_ls_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "ls") == NULL;
- str = getenv ("SKIP_TEST_LS_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_LS");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_ls_0 (void)
-{
- if (test_ls_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_ls_0");
- return 0;
- }
-
- /* InitBasicFS for test_ls_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputList for ls (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newer";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/newest";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char directory[] = "/";
- char **r;
- int i;
- suppress_error = 0;
- r = guestfs_ls (g, directory);
- if (r == NULL)
- return -1;
- if (!r[0]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "lost+found";
- if (strcmp (r[0], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
- return -1;
- }
- }
- if (!r[1]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "new";
- if (strcmp (r[1], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
- return -1;
- }
- }
- if (!r[2]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "newer";
- if (strcmp (r[2], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
- return -1;
- }
- }
- if (!r[3]) {
- fprintf (stderr, "test_ls_0: short list returned from command\n");
- print_strings (r);
- return -1;
- }
- {
- char expected[] = "newest";
- if (strcmp (r[3], expected) != 0) {
- fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
- return -1;
- }
- }
- if (r[4] != NULL) {
- fprintf (stderr, "test_ls_0: extra elements returned from command\n");
- print_strings (r);
- return -1;
- }
- for (i = 0; r[i] != NULL; ++i)
- free (r[i]);
- free (r);
- }
- return 0;
-}
-
-static int test_cat_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "cat") == NULL;
- str = getenv ("SKIP_TEST_CAT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_CAT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_cat_0 (void)
-{
- if (test_cat_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_cat_0");
- return 0;
- }
-
- /* InitBasicFS for test_cat_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutput for cat (0) */
- char expected[] = "new file contents";
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-static int test_touch_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "touch") == NULL;
- str = getenv ("SKIP_TEST_TOUCH_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_TOUCH");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_touch_0 (void)
-{
- if (test_touch_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_touch_0");
- return 0;
- }
-
- /* InitBasicFS for test_touch_0: create ext2 on /dev/sda1 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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 device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- /* TestOutputTrue for touch (0) */
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_touch (g, path);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- int r;
- suppress_error = 0;
- r = guestfs_exists (g, path);
- if (r == -1)
- return -1;
- if (!r) {
- fprintf (stderr, "test_touch_0: expected true, got false\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int test_sync_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "sync") == NULL;
- str = getenv ("SKIP_TEST_SYNC_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_SYNC");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_sync_0 (void)
-{
- if (test_sync_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_sync_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_sync_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestRun for sync (0) */
- {
- int r;
- suppress_error = 0;
- r = guestfs_sync (g);
- if (r == -1)
- return -1;
- }
- return 0;
-}
-
-static int test_mount_0_skip (void)
-{
- const char *str;
-
- str = getenv ("TEST_ONLY");
- if (str)
- return strstr (str, "mount") == NULL;
- str = getenv ("SKIP_TEST_MOUNT_0");
- if (str && strcmp (str, "1") == 0) return 1;
- str = getenv ("SKIP_TEST_MOUNT");
- if (str && strcmp (str, "1") == 0) return 1;
- return 0;
-}
-
-static int test_mount_0 (void)
-{
- if (test_mount_0_skip ()) {
- printf (" %s skipped (reason: environment variable set)\n", "test_mount_0");
- return 0;
- }
-
- /* InitNone|InitEmpty for test_mount_0 */
- {
- char device[] = "/dev/sda";
- int r;
- suppress_error = 0;
- r = guestfs_blockdev_setrw (g, device);
- if (r == -1)
- return -1;
- }
- {
- 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;
- }
- /* TestOutput for mount (0) */
- char expected[] = "new file contents";
- {
- char device[] = "/dev/sda";
- char lines_0[] = ",";
- char *lines[] = {
- lines_0,
- NULL
- };
- int r;
- suppress_error = 0;
- r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
- if (r == -1)
- return -1;
- }
- {
- char fstype[] = "ext2";
- char device[] = "/dev/sda1";
- int r;
- suppress_error = 0;
- r = guestfs_mkfs (g, fstype, device);
- if (r == -1)
- return -1;
- }
- {
- char device[] = "/dev/sda1";
- char mountpoint[] = "/";
- int r;
- suppress_error = 0;
- r = guestfs_mount (g, device, mountpoint);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char content[] = "new file contents";
- int r;
- suppress_error = 0;
- r = guestfs_write_file (g, path, content, 0);
- if (r == -1)
- return -1;
- }
- {
- char path[] = "/new";
- char *r;
- suppress_error = 0;
- r = guestfs_cat (g, path);
- if (r == NULL)
- return -1;
- if (strcmp (r, expected) != 0) {
- fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
- return -1;
- }
- free (r);
- }
- return 0;
-}
-
-int main (int argc, char *argv[])
-{
- char c = 0;
- int failed = 0;
- const char *filename;
- int fd;
- int nr_tests, test_num = 0;
-
- setbuf (stdout, NULL);
-
- no_test_warnings ();
-
- g = guestfs_create ();
- if (g == NULL) {
- printf ("guestfs_create FAILED\n");
- exit (1);
- }
-
- guestfs_set_error_handler (g, print_error, NULL);
-
- guestfs_set_path (g, "../appliance");
-
- filename = "test1.img";
- fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
- if (fd == -1) {
- perror (filename);
- exit (1);
- }
- if (lseek (fd, 524288000, SEEK_SET) == -1) {
- perror ("lseek");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (write (fd, &c, 1) == -1) {
- perror ("write");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (close (fd) == -1) {
- perror (filename);
- unlink (filename);
- exit (1);
- }
- if (guestfs_add_drive (g, filename) == -1) {
- printf ("guestfs_add_drive %s FAILED\n", filename);
- exit (1);
- }
-
- filename = "test2.img";
- fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
- if (fd == -1) {
- perror (filename);
- exit (1);
- }
- if (lseek (fd, 52428800, SEEK_SET) == -1) {
- perror ("lseek");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (write (fd, &c, 1) == -1) {
- perror ("write");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (close (fd) == -1) {
- perror (filename);
- unlink (filename);
- exit (1);
- }
- if (guestfs_add_drive (g, filename) == -1) {
- printf ("guestfs_add_drive %s FAILED\n", filename);
- exit (1);
- }
-
- filename = "test3.img";
- fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
- if (fd == -1) {
- perror (filename);
- exit (1);
- }
- if (lseek (fd, 10485760, SEEK_SET) == -1) {
- perror ("lseek");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (write (fd, &c, 1) == -1) {
- perror ("write");
- close (fd);
- unlink (filename);
- exit (1);
- }
- if (close (fd) == -1) {
- perror (filename);
- unlink (filename);
- exit (1);
- }
- if (guestfs_add_drive (g, filename) == -1) {
- printf ("guestfs_add_drive %s FAILED\n", filename);
- exit (1);
- }
-
- if (guestfs_add_drive_ro (g, "../images/test.sqsh") == -1) {
- printf ("guestfs_add_drive_ro ../images/test.sqsh FAILED\n");
- exit (1);
- }
-
- if (guestfs_launch (g) == -1) {
- printf ("guestfs_launch FAILED\n");
- exit (1);
- }
-
- /* Set a timeout in case qemu hangs during launch (RHBZ#505329). */
- alarm (600);
-
- if (guestfs_wait_ready (g) == -1) {
- printf ("guestfs_wait_ready FAILED\n");
- exit (1);
- }
-
- /* Cancel previous alarm. */
- alarm (0);
-
- nr_tests = 174;
-
- test_num++;
- printf ("%3d/%3d test_mknod_c_0\n", test_num, nr_tests);
- if (test_mknod_c_0 () == -1) {
- printf ("test_mknod_c_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mknod_b_0\n", test_num, nr_tests);
- if (test_mknod_b_0 () == -1) {
- printf ("test_mknod_b_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkfifo_0\n", test_num, nr_tests);
- if (test_mkfifo_0 () == -1) {
- printf ("test_mkfifo_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mknod_0\n", test_num, nr_tests);
- if (test_mknod_0 () == -1) {
- printf ("test_mknod_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mknod_1\n", test_num, nr_tests);
- if (test_mknod_1 () == -1) {
- printf ("test_mknod_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkswap_U_0\n", test_num, nr_tests);
- if (test_mkswap_U_0 () == -1) {
- printf ("test_mkswap_U_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkswap_L_0\n", test_num, nr_tests);
- if (test_mkswap_L_0 () == -1) {
- printf ("test_mkswap_L_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkswap_0\n", test_num, nr_tests);
- if (test_mkswap_0 () == -1) {
- printf ("test_mkswap_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_initrd_list_0\n", test_num, nr_tests);
- if (test_initrd_list_0 () == -1) {
- printf ("test_initrd_list_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_du_0\n", test_num, nr_tests);
- if (test_du_0 () == -1) {
- printf ("test_du_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_n_0\n", test_num, nr_tests);
- if (test_tail_n_0 () == -1) {
- printf ("test_tail_n_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_n_1\n", test_num, nr_tests);
- if (test_tail_n_1 () == -1) {
- printf ("test_tail_n_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_n_2\n", test_num, nr_tests);
- if (test_tail_n_2 () == -1) {
- printf ("test_tail_n_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tail_0\n", test_num, nr_tests);
- if (test_tail_0 () == -1) {
- printf ("test_tail_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_n_0\n", test_num, nr_tests);
- if (test_head_n_0 () == -1) {
- printf ("test_head_n_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_n_1\n", test_num, nr_tests);
- if (test_head_n_1 () == -1) {
- printf ("test_head_n_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_n_2\n", test_num, nr_tests);
- if (test_head_n_2 () == -1) {
- printf ("test_head_n_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_head_0\n", test_num, nr_tests);
- if (test_head_0 () == -1) {
- printf ("test_head_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_wc_c_0\n", test_num, nr_tests);
- if (test_wc_c_0 () == -1) {
- printf ("test_wc_c_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_wc_w_0\n", test_num, nr_tests);
- if (test_wc_w_0 () == -1) {
- printf ("test_wc_w_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_wc_l_0\n", test_num, nr_tests);
- if (test_wc_l_0 () == -1) {
- printf ("test_wc_l_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdtemp_0\n", test_num, nr_tests);
- if (test_mkdtemp_0 () == -1) {
- printf ("test_mkdtemp_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_scrub_file_0\n", test_num, nr_tests);
- if (test_scrub_file_0 () == -1) {
- printf ("test_scrub_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_scrub_device_0\n", test_num, nr_tests);
- if (test_scrub_device_0 () == -1) {
- printf ("test_scrub_device_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_glob_expand_0\n", test_num, nr_tests);
- if (test_glob_expand_0 () == -1) {
- printf ("test_glob_expand_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_glob_expand_1\n", test_num, nr_tests);
- if (test_glob_expand_1 () == -1) {
- printf ("test_glob_expand_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_glob_expand_2\n", test_num, nr_tests);
- if (test_glob_expand_2 () == -1) {
- printf ("test_glob_expand_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ntfs_3g_probe_0\n", test_num, nr_tests);
- if (test_ntfs_3g_probe_0 () == -1) {
- printf ("test_ntfs_3g_probe_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ntfs_3g_probe_1\n", test_num, nr_tests);
- if (test_ntfs_3g_probe_1 () == -1) {
- printf ("test_ntfs_3g_probe_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_sleep_0\n", test_num, nr_tests);
- if (test_sleep_0 () == -1) {
- printf ("test_sleep_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_find_0\n", test_num, nr_tests);
- if (test_find_0 () == -1) {
- printf ("test_find_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_find_1\n", test_num, nr_tests);
- if (test_find_1 () == -1) {
- printf ("test_find_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_find_2\n", test_num, nr_tests);
- if (test_find_2 () == -1) {
- printf ("test_find_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvresize_0\n", test_num, nr_tests);
- if (test_lvresize_0 () == -1) {
- printf ("test_lvresize_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_zerofree_0\n", test_num, nr_tests);
- if (test_zerofree_0 () == -1) {
- printf ("test_zerofree_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
- if (test_hexdump_0 () == -1) {
- printf ("test_hexdump_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_hexdump_1\n", test_num, nr_tests);
- if (test_hexdump_1 () == -1) {
- printf ("test_hexdump_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
- if (test_strings_e_0 () == -1) {
- printf ("test_strings_e_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_e_1\n", test_num, nr_tests);
- if (test_strings_e_1 () == -1) {
- printf ("test_strings_e_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
- if (test_strings_0 () == -1) {
- printf ("test_strings_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_strings_1\n", test_num, nr_tests);
- if (test_strings_1 () == -1) {
- printf ("test_strings_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
- if (test_equal_0 () == -1) {
- printf ("test_equal_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
- if (test_equal_1 () == -1) {
- printf ("test_equal_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
- if (test_equal_2 () == -1) {
- printf ("test_equal_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
- if (test_ping_daemon_0 () == -1) {
- printf ("test_ping_daemon_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
- if (test_dmesg_0 () == -1) {
- printf ("test_dmesg_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
- if (test_drop_caches_0 () == -1) {
- printf ("test_drop_caches_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
- if (test_mv_0 () == -1) {
- printf ("test_mv_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
- if (test_mv_1 () == -1) {
- printf ("test_mv_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
- if (test_cp_a_0 () == -1) {
- printf ("test_cp_a_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
- if (test_cp_0 () == -1) {
- printf ("test_cp_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
- if (test_cp_1 () == -1) {
- printf ("test_cp_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
- if (test_cp_2 () == -1) {
- printf ("test_cp_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
- if (test_grub_install_0 () == -1) {
- printf ("test_grub_install_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
- if (test_zero_0 () == -1) {
- printf ("test_zero_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
- if (test_fsck_0 () == -1) {
- printf ("test_fsck_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
- if (test_fsck_1 () == -1) {
- printf ("test_fsck_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
- if (test_set_e2uuid_0 () == -1) {
- printf ("test_set_e2uuid_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
- if (test_set_e2uuid_1 () == -1) {
- printf ("test_set_e2uuid_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
- if (test_set_e2uuid_2 () == -1) {
- printf ("test_set_e2uuid_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
- if (test_set_e2uuid_3 () == -1) {
- printf ("test_set_e2uuid_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
- if (test_set_e2label_0 () == -1) {
- printf ("test_set_e2label_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
- if (test_pvremove_0 () == -1) {
- printf ("test_pvremove_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
- if (test_pvremove_1 () == -1) {
- printf ("test_pvremove_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
- if (test_pvremove_2 () == -1) {
- printf ("test_pvremove_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
- if (test_vgremove_0 () == -1) {
- printf ("test_vgremove_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
- if (test_vgremove_1 () == -1) {
- printf ("test_vgremove_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
- if (test_lvremove_0 () == -1) {
- printf ("test_lvremove_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
- if (test_lvremove_1 () == -1) {
- printf ("test_lvremove_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
- if (test_lvremove_2 () == -1) {
- printf ("test_lvremove_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
- if (test_mount_ro_0 () == -1) {
- printf ("test_mount_ro_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
- if (test_mount_ro_1 () == -1) {
- printf ("test_mount_ro_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
- if (test_tgz_in_0 () == -1) {
- printf ("test_tgz_in_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
- if (test_tar_in_0 () == -1) {
- printf ("test_tar_in_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
- if (test_checksum_0 () == -1) {
- printf ("test_checksum_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
- if (test_checksum_1 () == -1) {
- printf ("test_checksum_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
- if (test_checksum_2 () == -1) {
- printf ("test_checksum_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
- if (test_checksum_3 () == -1) {
- printf ("test_checksum_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
- if (test_checksum_4 () == -1) {
- printf ("test_checksum_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
- if (test_checksum_5 () == -1) {
- printf ("test_checksum_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
- if (test_checksum_6 () == -1) {
- printf ("test_checksum_6 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
- if (test_checksum_7 () == -1) {
- printf ("test_checksum_7 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_checksum_8\n", test_num, nr_tests);
- if (test_checksum_8 () == -1) {
- printf ("test_checksum_8 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
- if (test_download_0 () == -1) {
- printf ("test_download_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
- if (test_upload_0 () == -1) {
- printf ("test_upload_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
- if (test_blockdev_rereadpt_0 () == -1) {
- printf ("test_blockdev_rereadpt_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
- if (test_blockdev_flushbufs_0 () == -1) {
- printf ("test_blockdev_flushbufs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
- if (test_blockdev_getsize64_0 () == -1) {
- printf ("test_blockdev_getsize64_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
- if (test_blockdev_getsz_0 () == -1) {
- printf ("test_blockdev_getsz_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
- if (test_blockdev_getbsz_0 () == -1) {
- printf ("test_blockdev_getbsz_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
- if (test_blockdev_getss_0 () == -1) {
- printf ("test_blockdev_getss_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
- if (test_blockdev_getro_0 () == -1) {
- printf ("test_blockdev_getro_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
- if (test_blockdev_setrw_0 () == -1) {
- printf ("test_blockdev_setrw_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
- if (test_blockdev_setro_0 () == -1) {
- printf ("test_blockdev_setro_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
- if (test_statvfs_0 () == -1) {
- printf ("test_statvfs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
- if (test_lstat_0 () == -1) {
- printf ("test_lstat_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
- if (test_stat_0 () == -1) {
- printf ("test_stat_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_0\n", test_num, nr_tests);
- if (test_command_lines_0 () == -1) {
- printf ("test_command_lines_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_1\n", test_num, nr_tests);
- if (test_command_lines_1 () == -1) {
- printf ("test_command_lines_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_2\n", test_num, nr_tests);
- if (test_command_lines_2 () == -1) {
- printf ("test_command_lines_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_3\n", test_num, nr_tests);
- if (test_command_lines_3 () == -1) {
- printf ("test_command_lines_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_4\n", test_num, nr_tests);
- if (test_command_lines_4 () == -1) {
- printf ("test_command_lines_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_5\n", test_num, nr_tests);
- if (test_command_lines_5 () == -1) {
- printf ("test_command_lines_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_6\n", test_num, nr_tests);
- if (test_command_lines_6 () == -1) {
- printf ("test_command_lines_6 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_7\n", test_num, nr_tests);
- if (test_command_lines_7 () == -1) {
- printf ("test_command_lines_7 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_8\n", test_num, nr_tests);
- if (test_command_lines_8 () == -1) {
- printf ("test_command_lines_8 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_9\n", test_num, nr_tests);
- if (test_command_lines_9 () == -1) {
- printf ("test_command_lines_9 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_lines_10\n", test_num, nr_tests);
- if (test_command_lines_10 () == -1) {
- printf ("test_command_lines_10 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_0\n", test_num, nr_tests);
- if (test_command_0 () == -1) {
- printf ("test_command_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_1\n", test_num, nr_tests);
- if (test_command_1 () == -1) {
- printf ("test_command_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_2\n", test_num, nr_tests);
- if (test_command_2 () == -1) {
- printf ("test_command_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_3\n", test_num, nr_tests);
- if (test_command_3 () == -1) {
- printf ("test_command_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_4\n", test_num, nr_tests);
- if (test_command_4 () == -1) {
- printf ("test_command_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_5\n", test_num, nr_tests);
- if (test_command_5 () == -1) {
- printf ("test_command_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_6\n", test_num, nr_tests);
- if (test_command_6 () == -1) {
- printf ("test_command_6 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_7\n", test_num, nr_tests);
- if (test_command_7 () == -1) {
- printf ("test_command_7 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_8\n", test_num, nr_tests);
- if (test_command_8 () == -1) {
- printf ("test_command_8 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_9\n", test_num, nr_tests);
- if (test_command_9 () == -1) {
- printf ("test_command_9 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_10\n", test_num, nr_tests);
- if (test_command_10 () == -1) {
- printf ("test_command_10 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_command_11\n", test_num, nr_tests);
- if (test_command_11 () == -1) {
- printf ("test_command_11 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
- if (test_file_0 () == -1) {
- printf ("test_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
- if (test_file_1 () == -1) {
- printf ("test_file_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
- if (test_file_2 () == -1) {
- printf ("test_file_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
- if (test_umount_all_0 () == -1) {
- printf ("test_umount_all_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
- if (test_umount_all_1 () == -1) {
- printf ("test_umount_all_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
- if (test_mounts_0 () == -1) {
- printf ("test_mounts_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
- if (test_umount_0 () == -1) {
- printf ("test_umount_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
- if (test_umount_1 () == -1) {
- printf ("test_umount_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
- if (test_write_file_0 () == -1) {
- printf ("test_write_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
- if (test_write_file_1 () == -1) {
- printf ("test_write_file_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
- if (test_write_file_2 () == -1) {
- printf ("test_write_file_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
- if (test_write_file_3 () == -1) {
- printf ("test_write_file_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
- if (test_write_file_4 () == -1) {
- printf ("test_write_file_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
- if (test_write_file_5 () == -1) {
- printf ("test_write_file_5 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
- if (test_mkfs_0 () == -1) {
- printf ("test_mkfs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
- if (test_lvcreate_0 () == -1) {
- printf ("test_lvcreate_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
- if (test_vgcreate_0 () == -1) {
- printf ("test_vgcreate_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
- if (test_pvcreate_0 () == -1) {
- printf ("test_pvcreate_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
- if (test_is_dir_0 () == -1) {
- printf ("test_is_dir_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
- if (test_is_dir_1 () == -1) {
- printf ("test_is_dir_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
- if (test_is_file_0 () == -1) {
- printf ("test_is_file_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
- if (test_is_file_1 () == -1) {
- printf ("test_is_file_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
- if (test_exists_0 () == -1) {
- printf ("test_exists_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
- if (test_exists_1 () == -1) {
- printf ("test_exists_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
- if (test_mkdir_p_0 () == -1) {
- printf ("test_mkdir_p_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
- if (test_mkdir_p_1 () == -1) {
- printf ("test_mkdir_p_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
- if (test_mkdir_p_2 () == -1) {
- printf ("test_mkdir_p_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_3\n", test_num, nr_tests);
- if (test_mkdir_p_3 () == -1) {
- printf ("test_mkdir_p_3 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_p_4\n", test_num, nr_tests);
- if (test_mkdir_p_4 () == -1) {
- printf ("test_mkdir_p_4 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
- if (test_mkdir_0 () == -1) {
- printf ("test_mkdir_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
- if (test_mkdir_1 () == -1) {
- printf ("test_mkdir_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
- if (test_rm_rf_0 () == -1) {
- printf ("test_rm_rf_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
- if (test_rmdir_0 () == -1) {
- printf ("test_rmdir_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
- if (test_rmdir_1 () == -1) {
- printf ("test_rmdir_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
- if (test_rmdir_2 () == -1) {
- printf ("test_rmdir_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
- if (test_rm_0 () == -1) {
- printf ("test_rm_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
- if (test_rm_1 () == -1) {
- printf ("test_rm_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
- if (test_rm_2 () == -1) {
- printf ("test_rm_2 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
- if (test_read_lines_0 () == -1) {
- printf ("test_read_lines_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
- if (test_read_lines_1 () == -1) {
- printf ("test_read_lines_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
- if (test_lvs_0 () == -1) {
- printf ("test_lvs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
- if (test_lvs_1 () == -1) {
- printf ("test_lvs_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
- if (test_vgs_0 () == -1) {
- printf ("test_vgs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
- if (test_vgs_1 () == -1) {
- printf ("test_vgs_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
- if (test_pvs_0 () == -1) {
- printf ("test_pvs_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
- if (test_pvs_1 () == -1) {
- printf ("test_pvs_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
- if (test_list_partitions_0 () == -1) {
- printf ("test_list_partitions_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
- if (test_list_partitions_1 () == -1) {
- printf ("test_list_partitions_1 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
- if (test_list_devices_0 () == -1) {
- printf ("test_list_devices_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
- if (test_ls_0 () == -1) {
- printf ("test_ls_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
- if (test_cat_0 () == -1) {
- printf ("test_cat_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
- if (test_touch_0 () == -1) {
- printf ("test_touch_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
- if (test_sync_0 () == -1) {
- printf ("test_sync_0 FAILED\n");
- failed++;
- }
- test_num++;
- printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
- if (test_mount_0 () == -1) {
- printf ("test_mount_0 FAILED\n");
- failed++;
- }
-
- guestfs_close (g);
- unlink ("test1.img");
- unlink ("test2.img");
- unlink ("test3.img");
-
- if (failed > 0) {
- printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);
- exit (1);
- }
-
- exit (0);
-}